How would you stop a class from class from being derived or
inherited?The constructer should not be Private,as object
instantiation should be allowed.

Answer Posted / mms zubeir

Thanks for your detailed answer. It's good to see you have
achieved the purpose partially by using static methods.
Still, we cannot create objects on the stack rather it
allows to create objects only on the heap. This is because,
we have to call the destructor using delete. You have
provided static methods to do that.

The compiler will not allow to create stack objects since
it cannot be able to invoke the destructor when unwinding
stack.

I do not have an idea how to fulfill this requirement.
Anyway, you have rolled out the solution to some extent.
Thanks.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How many standards of c++ are there?

634


Describe the syntax of single inheritance in C++?

651


How java is different from c and c++?

656


What is the need of a destructor? Explain with the help of an example.

576


Why null pointer is used?

591






What is a class definition?

620


Explain the difference between using macro and inline functions?

584


Write some differences between an external iterator and an internal iterator? Describe the advantage of an external iterator.

617


What are member functions used in c++?

566


What are features of c++?

643


What is friend class in c++ with example?

512


How important is c++?

536


Describe the advantages of operator overloading?

579


Why is c++ considered difficult?

655


How do c++ struct differs from the c++ class?

594