Dear friends,
can constructor be private or not if yes How it possible ?
sanjay
hi there,
Constructors cannot be called explicitly as if they were regular member functions. They are only executed when a new object of that class is created.
You can also see how neither the prototype nor the later constructor declaration includes a return value; not even void.
Like any other function, a constructor can also be overloaded with more than one function that have the same name but different types or number of parameters. Remember that for overloaded functions the compiler will call the one whose parameters match the arguments used in the function call. In the case of constructors, which are automatically called when an object is created, the one executed is the one that matches the arguments passed on the object declaration:
If you do not declare any constructors in a class definition, the compiler assumes the class to have a default constructor with no arguments.
so it is better to put then in public not on private..
regards,