摘要:
#include <iostream>using namespace std;class Class{public:virtual void fun(){cout << "Class::fun" << endl;}};int main(){Class objClass;cout << "Size of Class = " << sizeof(objClass) << endl;return 0;}Size of Class = 4#include <iostream>us 阅读全文
posted @ 2012-07-19 20:19
byfei
阅读(466)
评论(0)
推荐(0)
摘要:
#include <iostream>using namespace std;template<typename T>class CPoint{public:T m_x;T m_y;};int main(){CPoint<int> objPoint;cout << "Size of object is = " << sizeof(objPoint) << endl;return 0;}Size of object Point is = 8#include <iostream>using na 阅读全文
posted @ 2012-07-19 19:58
byfei
阅读(136)
评论(0)
推荐(0)
摘要:
#include <iostream>using namespace std;class Base{public:Base(){cout << "In Base" << endl;cout << "This Pointer = " << (int*) this << endl;cout << endl;}virtual void f(){cout << "Base::f" << endl;}};class Drive: publ 阅读全文
posted @ 2012-07-19 19:05
byfei
阅读(119)
评论(0)
推荐(0)
摘要:
#include <iostream>using namespace std;class Base{public:virtual void fun(){cout << "Base::fun" << endl;}void show(){fun();}};class Drive: public Base{public:virtual void fun(){cout << "Drive::fun" << endl;}};int main(){Drive d;d.show();d.fun();retur 阅读全文
posted @ 2012-07-19 17:52
byfei
阅读(125)
评论(0)
推荐(0)
摘要:
1.这个程序清楚地示范了基类的函数是如何调用派生类的虚函数的。这一技术被用于不同的框架中,例如MFC和设计模式(比如Template Design Pattern)。现在你可以修改一下这个程序来看看它的行为,我将要在基类的构造函数中调用虚函数,而不是普通的成员... 阅读全文
posted @ 2012-07-19 17:52
byfei
阅读(57)
评论(0)
推荐(0)

浙公网安备 33010602011771号