Technical Discussion :: C++
Home > Technical Interview Q&A > C++ > Discussion
93 / 187
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 ::
Ranjana
23 Feb, 2019 5:07 AM
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.