Technical Discussion :: C++
Home > Freshers > Technical Interview Questions > C++
9. What is default constructor. Give example?
Answer:
A constructor that accepts no parameters is called the default constructor. The default constructor for class A is A::A ( ). If no such constructor is defined, then the compiler supplies a default constructor. Therefore a statement such as A a;
Invokes the default constructor of the compiler to create the object a.
Asked In :: Societe Generale
A constructor that accepts no parameters is called the default constructor. The default constructor for class A is A::A ( ). If no such constructor is defined, then the compiler supplies a default constructor. Therefore a statement such as A a;
Invokes the default constructor of the compiler to create the object a.
Invokes the default constructor of the compiler to create the object a.