-
Default Constructors
I have one question regarding default constructors. In java you have a constructor to instantiate objects, but constructors in C++, are used initialize instance variables. If a default constructor doesnt initialize any of the variables, what is the point of one?
Thanks
-
The default constructor generated automatically by the constructor will do the same any other constructor does, namely - make sure the object is in a usable state (that is, initialize anything implementation specific). It will also call the default constructors for base classes and member objects.
A default constructor written by you can do just about anything.
-
C++ add a dimension to and already extensible programming language with partial unitialization in the contractors and as function parameters.
Code:
class X
{
X();
X(int a = 0, b = 1, char z = TEXT("October"));
virtual ~X();
}
Kuphryn