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

What are the desktop applications?

629


Why do I get a security exception when I try to run my c# app?

747


What is an enumerator c#?

679


What is dataview c#?

609


Which function is the entry point for a DLL in MS Windows 3.1?

858






Define using statement in c#?

677


What are the problem with .NET generics?

720


Can we override interface method?

715


Is .net and c# the same?

710


How do you use nullable?

656


When should we use delegates in c#?

658


What is private virtual in C#?

744


How can we set the class to be inherited, but prevent the method from being over-ridden?

654


Why do we need delegates in c#?

700


What is concatenation and when should it be used?

674