Why we can't create the object of abstract class ?

Answer Posted / abhishek ajmera

When we declare a pure virtual function like this:-

Virtual PureVirtualFunction()=0;

This indicates compiler to reserve a slot for Function in VTABLE but don’t put an address in that particular slot. If only one function in a class is declared as pure virtual, the VTABLE is incomplete.
If the VTABLE for a class is incomplete, compiler cannot safely create an object of a pure abstract class, so you get an error message from the compiler if you try to make an object of a pure abstract class. Thus, the compiler ensures the purity of the abstract class, and you don’t have to worry about misusing it.

Is This Answer Correct ?    10 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain a MSIL ? Why is it appreciated by all developers?

592


Does google use c#?

520


Why do we need interface in c#?

506


What is a static field?

511


What is yield return in c#?

495






What does the dispose method do with the connection object?

537


What is a delegate? How can it works?

527


Is list passed by reference c#?

481


Is null empty or whitespace c#?

505


Explain how do I convert a string to an int in c#?

520


What is an inheritance ?Give an example in which inheritance is used?

532


What is c sharp language?

516


Is datetime a value type in c#?

495


What are the benefits of using the aggregate method in linq?

505


What is the namespace for the thread class?

520