标签:虚函数表 poi ++ 参考 ext span 成员 const bsp
class A {}; class B : public virtual A {}; class C : public virtual A {}; class D : public B, public C {}; int main() { A a; B b; C c; D d; cout << sizeof(a) << endl; cout << sizeof(b) << endl; cout << sizeof(c) << endl; cout << sizeof(d) << endl; getchar(); return 0; } class A {}; class B : public virtual A {}; class C : public virtual A {}; class D : public B, public C {}; int main() { A a; B b; C c; D d; cout << sizeof(a) << endl; cout << sizeof(b) << endl; cout << sizeof(c) << endl; cout << sizeof(d) << endl; getchar(); return 0; }
class base { int val; char a; } class derived : public base { char b; } derived * p2; base* p1_1,*p1_2; p1_1=p2; *p1_2=*p1_1;
int main() { char *mem; A a; B b; C c; A *pa1, *pa2 = new A; B *pb=new B; pa2->str1 = ‘A‘; pb->str2 = ‘B‘; pb->a = 2; pb->str1 = ‘b‘; pa1 = pb; *pa2 = *pa1; mem = (char*)pa1; HexDump(mem, 16, (int)mem); mem = (char*)pa2; HexDump(mem, 16, (int)mem); getchar(); return 0; }
class Point2d { public: virtual void fun1() {}; protected: float x_, y_; }; class Point3d :public Point2d { protected: float z_; }; class Vertex { public: virtual void fun2() {}; protected: Vertex * next; }; class Vertex3d :public Point3d, public Vertex { protected: float mumble; }; int main() { Vertex3d v3d; Vertex3d * pv3d = &v3d; Vertex *pv=new Vertex; Point2d *p2d =new Point2d; Point3d *p3d= new Point3d; pv = &v3d; p2d = &v3d; p3d = &v3d; printf("%p\n",&v3d); getchar(); return 0; }
class Point2d { public: virtual void fun1() {}; protected: float x_, y_; }; class Point3d :public virtual Point2d { public: void operator+=(const Point3d &rhs) { x_ += rhs.x_; y_ += rhs.y_; z_ += rhs.z_; } protected: float z_; }; class Vertex:public virtual Point2d { public: virtual void fun2() {}; protected: Vertex * next; }; class Vertex3d :public Vertex,public Point3d { protected: float mumble; }; int main() { Vertex3d v3d; Vertex3d * pv3d = &v3d; Vertex *pv = new Vertex; Point2d *p2d = new Point2d; Point3d *p3d = new Point3d; p2d = pv3d; printf("%p\n", &v3d); getchar(); return 0; }
标签:虚函数表 poi ++ 参考 ext span 成员 const bsp
原文地址:http://www.cnblogs.com/fancystar/p/6017869.html