C++ Programming - Constructors and Destructors - Discussion
Discussion Forum : Constructors and Destructors - General Questions (Q.No. 16)
16.
Constructors __________ to allow different approaches of object construction.
Discussion:
3 comments Page 1 of 1.
Najmus said:
6 years ago
#include<iostream>
using namespace std;
class A
{
public : A()
{
cout<<"Default constructor"<<endl;
}
~A()
{
cout<<"Default destructor"<<endl;
}
};
int main()
{
A o1;
A o2;
A o3;
}
Result :Can be overloaded.
using namespace std;
class A
{
public : A()
{
cout<<"Default constructor"<<endl;
}
~A()
{
cout<<"Default destructor"<<endl;
}
};
int main()
{
A o1;
A o2;
A o3;
}
Result :Can be overloaded.
Umakant said:
1 decade ago
We all know that the use of constructor is to simply initialize the object. But if you want to initialize more than one object in same prog/same scope then we can call again constructor explicitly to initialize the object and this is nothing but ""Can be overloaded"".
Prakas.s said:
4 years ago
Yes, you are right, thanks @Najmus.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers