Why cant one make an object of abstract class?Give compiler view of statement

Showing Answers 1 - 8 of 8 Answers

we cant make object of abstract class becoz, in the vtable the vtable entry for the abstract class functions will be NULL, which ever are defined as pure virtual functions...

even if there is a single pure virtual function in the class the class becomes as abstract class..

if there is a virtual function in your class the compiler automatically creates a table called virtual function table .. to store the virtual function addresses.... if the function is a pure virtual function the vtable entry for that function will be NULL.

even if there is a single NULL entry in the function table the compiler does not allow to create the object.

Prateek Joshi

  • Oct 8th, 2006
 

Hello,

Abstract classss r the classs that contain atleast one pure virtual funtion.

Abstract clas cannot b instantised so it is irrelevent to create the obj of this classs

Raju

  • Mar 26th, 2007
 

Abstract class contain one Pure virtual function.., in order to Create an object we must override this to Derived class, otherwise derived class function become Abstract class.So Abstract Class should be override in Derived class.

  Was this answer useful?  Yes

Raju

  • Mar 27th, 2007
 

look this code which tells we can Create an object for pure virtual function:

Class Base
{
  public:
 virtual void fun()=0;

};
class deri:public base
{
 void fun()
{
  cout<<"i am here";
}
base::fun();

main()
{
deri d;
d.fun();
}

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions