Answer Posted / binoy mathew
private: // note that constructor is private here
t *t1 = new t; // create a new obj
delete t1; // delete the obj, which calls destructor
Try to compile the above code.
following error results...
[root@localhost Desktop]# g++ test.cpp
test.cpp: In function ‘int main()’:
test.cpp:13: error: ‘t::~t()’ is private
tt.cpp:: error: within this context
....implies, we can't have destructor private.
|Is This Answer Correct ?||1 Yes||3 No|
Is c++ a software?
What are friend functions in C++?
What is a singleton c++?
What is the use of setfill in c++?
Differentiate between a template class and class template in c++?
Is java made in c++?
Why do we use string in c++?
What is anonymous object in c++?
Which should be more useful: the protected and public virtuals?
What is c++ hiding?
What are the sizes and ranges of the basic c++ data types?
Using a smart pointer can we iterate through a container?
Can you pass a vector to a function?
What is a unnitialised pointer?
Define copy constructor.