Ad Code

Constructors can have parameters

Constructors can have parameters  can you explain more with other examples?


Overloading constructors, like overloading other function names, is just the practice of defining more than one constructor for a class, each taking a different set of parameters:

class A
{
public:
        A();                   // Default constructor
        A( A const & other );  // Copy constructor
A(char, int);
A(int);
A(char);
// ...
};
Reactions

Post a Comment

0 Comments