Saturday, 31 August 2013

Use of public destructor when the constructor is private. (C++)

Use of public destructor when the constructor is private. (C++)

I have seen code where the constructor has been declared as private while
the destructor is public. What is the use of such a declaration? Is the
destructor required to be public so that during inheritance the calls can
be possible or is it a bug in the code?
The question might seem to be a little less with information but what I
really want to know is that having a public desctructor when the
constructor is required to be public abides by the C++ rules?

No comments:

Post a Comment