The vptr index should display all the virtual functions, but in my case only 2 out of the 3 virtual functions are being displayed.
I am providing the complete code and the screenshots below :-
ClassHeader.h
#include <iostream>
using namespace std;
// Employee Class
class Employee
{
public :
int salary ;
Employee(){cout << "Inside CTOR" << endl;}
virtual ~Employee() {cout << "Inside DTOR" << endl;}
virtual void pay(){cout << "Employee" << endl;}
};
// Manager Class
class Manager : public Employee
{
public :
virtual void pay(){cout<< "Manager pay" << endl;}
virtual void Rank(){cout << "Manager Rank" << endl;}
};
// JuniorManager Class
class JuniorManager : public Manager
{
public :
virtual void pay(){cout<< "JuniorManager pay" << endl;}
virtual void Rank(){cout << "JuniorManager Rank" << endl;}
};
Main.cpp
#include "ClassHeader.h"
void main()
{
Manager *p = new Manager();
p->pay();
p->Rank();
p = new JuniorManager();
p->Rank();
Employee *pE = dynamic_cast<Employee*>(p);
pE->pay();
}
The Manager class has two virtual functions, pay and Rank, but only pay shows up in the vptr.
Can somebody please tell me, why Rank does not show up , even though its virtual function.
I am using Visual Studio 2008 , and with the latest updates, on Windows 7 64 bit.
JuniorManager Debugger Screenshot
It does not show the virtual functions either. Please see the image below.