Constructor In C++ -: In the c++ programming language A constructors is a special member function whose task is to initialize the object of its class. It is a special because its name is the same as the class name. The constructors is involved whenever an object of its associated class is created. It is called constructors because it construct the values of data member of the class.
Characteristic for define the constructors -: There are some special character for defining the constructors function these are ..
Types of Constructors in c++ programming language-: In the C++ programming language constructor has many types these are
How the constructor declared and defined
//class with a constructor class integer { int a, b; public: integer (void); // constructor declared ........... ........... }; integer :: integer (void) //constructors defined { a=0; b=0; }
Characteristic for define the constructors -: There are some special character for defining the constructors function these are ..
- Constructor should be declared in public section.
- It can not inherited through a derived class can call the base class constructor.
- These are invoked automatically when the object are created.
- we can not refers to their address.
- constructor do not have any return type not even void and therefore and they cannot return values.
- Like any other c++ function they can have default arguments.
- Constructor can not be used as a member of a union.
- constructor make 'implicit value' to the operator new and delete when memory allocation is require.
- constructor can not be virtual.
Types of Constructors in c++ programming language-: In the C++ programming language constructor has many types these are
- Parameterized Constructors
- Multiple Constructor in class
- Default constructors
- Dynamic Initialization constructors
- Copy Constructors
- Dynamic Construction
- Constructing Two dimension array.
No comments:
Post a Comment