-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDefault-constructor-code.cpp
58 lines (51 loc) · 1.47 KB
/
Default-constructor-code.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/**
* @brief This program demonstrates the usage of a simple class representing flowers.
*
* The program defines a class called 'flower' with private member variables for two flower names.
* It includes a default constructor that initializes the flower names and prints out a message.
* The main function creates an instance of the flower class and terminates the program.
*/
// Including Header File
#include <iostream>
// Using Namespace
using namespace std;
// Defining the flower class
class flower
{
private:
string f1;
string f2;
public:
/**
* @brief Default constructor for the flower class.
*
* This constructor initializes the private member variables f1 and f2 with default values.
* It also prints out a message indicating that the default constructor has been called,
* along with the names of the two flowers.
*
* @param None
* @return None
*/
flower()
{
f1 = "Lily";
f2 = "Rose";
cout << "Default constructor is called" << endl;
cout << "First flower is:" << f1 << endl;
cout << "Second flower is:" << f2 << endl;
}
};
/**
* @brief The main function of the program.
*
* This function serves as the entry point for the program. It creates an instance of the flower class
* and then returns 0 to indicate successful program termination.
*
* @param None
* @return 0 - Indicates successful program termination.
*/
int main()
{
flower fl;
return 0;
}