How would you stop a class from class from being derived or
inherited.
Answers were Sorted based on User's Feedback
Answer / stavan
By Creating class as a private.
It will not allow that class to inherited.
private class A{
// code
}
class B extends A{ // It will not work.
// Code
}
| Is This Answer Correct ? | 0 Yes | 1 No |
Answer / abhijit
class ASealedClass;
class MyFinalClass
{
friend ASealedClass;
private:
MyFinalClass(int dummy) {}
};
class ASealedClass : virtual MyFinalClass
{
public:
ASealedClass() : MyFinalClass(0) {} // this is the key .. it
is the virtual inheritance that prevents inheritance
};
| Is This Answer Correct ? | 1 Yes | 4 No |
Answer / abhi
I think by making all data msmbers and member functions
protected..
May be this is soln
| Is This Answer Correct ? | 0 Yes | 4 No |
Answer / vishaka
The class shoul be made abstract to stop it from being
derived or inherited. To make a class abstract, it should
have atleast one pure virtual function.
| Is This Answer Correct ? | 2 Yes | 21 No |
What exactly is polymorphism?
What is polymorphism oop?
Why multiple inheritance is not allowed?
what about you? wahat is your object? introduce your self?
1 Answers Ajmal Perfumes, TCS,
OOP'S advantages of inheritance include:
A file pointer always contains the __________ of the file
In c++ there is only virtual destructors, no constructors. Why?
What is a template?
Why do we use virtual functions?
What is the importance of oop?
What is the concept of object oriented program?
features of OOPS
22 Answers Ness Technologies, Satyam,