Click here to Skip to main content
15,886,578 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Everyone,

Can you please answer below question?

A class has virtual n number of functions. How many virtual pointer will be there in the class?

Regards,
Joy
Posted
Comments
chandanadhikari 3-Apr-14 3:33am    
well if you ask for a pointer to the vtable of a polymorphic class then a class with a virtual method will have a single vtable and this vtable is shared by all objects of this class.
Each object instance of this class will have its own pointer to that vtable , typically called a virtual pointer or vptr. The compiler implicitly generates code to initialize the vptr in the constructor. So, thers is 1 virtual pointer per object instance.

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900