codeArt

codeArt

用在COM中,类行为比较怪异的代码

#include <iostream>

using namespace std;

template <typename T>
class Base {
public:
void fun() {
cout << "Base::fun" << endl;
}

void doSomething() {
T* pT = static_cast<T*>(this);
pT->fun();
}
};

class Drive : public Base<Drive> {
public:
void fun() {
cout << "Drive::fun" << endl;
}
};

class MostDrive : public Drive {
public:
void fun() {
cout << "MostDrive::fun" << endl;
}
};

int main() {
MostDrive obj;
obj.doSomething();

return 0;
}

posted on 2010-08-27 21:02 codeArt 阅读(322) 评论(0)  编辑 收藏 引用

<2025年10月>
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

导航

统计

常用链接

留言簿(1)

随笔分类

随笔档案

文章档案

编程与开源

搜索

最新评论

阅读排行榜

评论排行榜