| 1. |
What Is The Memory Structure Of An Object? |
|
Answer» Usually C++ objects are MADE by concatenating MEMBER VARIABLES. For example; class Test { int i; float j; }; is represented by an int followed by a float. class TestSub: public Test { int K; }; The above class is represented by Test and then an int(for int k). So FINALLY it will be int, float and int. In addition to this each object will have the vptr(virtual pointer) if the class has virtual function, usually as the first element in a class. Usually C++ objects are made by concatenating member variables. For example; class Test { int i; float j; }; is represented by an int followed by a float. class TestSub: public Test { int k; }; The above class is represented by Test and then an int(for int k). So finally it will be int, float and int. In addition to this each object will have the vptr(virtual pointer) if the class has virtual function, usually as the first element in a class. |
|