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);
// ...
};
class A
{
public:
A(); // Default constructor
A( A const & other ); // Copy constructor
A(char, int);
A(int);
A(char);
// ...
};
0 Comments
Please add nice comments or answer ....