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 is runtime polymorphism? For the 5 marks.
create a class complex having real and imaginary part of a complex no. as a data member. overload the binary operators(+,- and *) to perform the operations on complex no. objects. overload binary operator using friend function.
2 Answers CTS, Delhi University,
what is an qt4 interface?
what is the need of abstraction? what is abstraction?what is the abstraction for stack?
What is abstract class in oops?
What is the use of oops?
WHY FUCTION OVERLOADING DOSENOT RETURN A RETEN TYPE
what about you? wahat is your object? introduce your self?
1 Answers Ajmal Perfumes, TCS,
which are the 4 members functions in c++ objects that can either be declared explicitly by programmer or implementation if nt available.
what is ns string? what is ns array?
what is abstract class ? when is used in real time ? give a exp
WHEN A COPY CONSTER IS CALL ?