Q:

How to make a C++ class whose objects can only be dynamically allocated?

0

How to make a C++ class whose objects can only be dynamically allocated?

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Answer:

Create a private destructor in the class. When you make a private destructor, the compiler would generate a compiler error for non-dynamically allocated objects because the compiler needs to remove them from the stack segment once they are not in use.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C++ Interview Questions For Experienced

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
What does the explicit keyword mean?... >>
<< How does the compilation/linking process work in c...