The simple answer to why the destructor should be made private is that theprogrammer doesn't want anyone to be able to destroy the object.
And the private destructor behavior depends upon the compiler in use. The GNU compiler collection does not allow inheritance from a class whose destructor is private.
If inheritence is required then the destructor should be made protected.
costructor destructor can be private......that make the class final class i.e......this class can't be inherited(because canot be instenteniet from out side of the class). Only one static method in that class can create obj. and return for use.
Monday, August 17, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment