Home > Back-end >  If a class defines a virtual destructor, and multiple virtual function, so the class will include mo
If a class defines a virtual destructor, and multiple virtual function, so the class will include mo

Time:09-22

 
#include
using namespace std;

The class Person {
Public:
The Person (s) : code (100) {}
Virtual ~ Person () {}
Virtual void attack () {}
Int code;
};

Int main ()
{
The Person Man;
Int * p=(int *) & amp; Man;
cout <(* p) (unsigned int) & lt; //the output for the virtual function table address
P++;
cout <(* p) (unsigned int) & lt;
system("pause");
return 0;
}


Has passed the above code to prove that a class only up to a virtual function table, is wrong?

CodePudding user response:

My understanding is that only a virtual function table, each item in the table, is a virtual function pointer,

CodePudding user response:

CB support two kinds, c + + class (has nothing to do with TObject) and Delphi class (directly or indirectly from TObject derived), according to my understanding, the c + + classes can be no VMT, Delphi class must have a,
  • Related