COM聚合的简单模拟
来源:互联网 发布:软件测试环路复杂度 编辑:程序博客网 时间:2024/04/29 04:59
COM中的聚合原理看起来比较简单,但是由于其要实现两个IUnknown,所以实现起来比包容复杂,下面我做了个简单的模拟程序,看起来就比较容易理解,代码如下:
#include <iostream.h>
class IUnknown
{
public:
virtual void funcM() = 0;
virtual void funcN() = 0;
virtual void funcP() = 0;
};
class INondelegation
{
public:
virtual void nonfuncM() = 0;
virtual void nonfuncN() = 0;
virtual void nonfuncP() = 0;
};
class A : public IUnknown
{
public:
virtual void funcM();
virtual void funcN();
virtual void funcP();
};
#if 1
void A::funcM()
{
cout<<"class A funcM IUnknown"<<endl;
}
void A::funcN()
{
cout<<"class A funcN IUnknown"<<endl;
}
void A::funcP()
{
cout<<"class A funcP IUnknown"<<endl;
}
#endif
class B : public A,
public INondelegation
{
public:
B::B();
virtual void funcM()
{
cout<<"class B funcM - INondelegation"<<endl;
}
virtual void funcN()
{
cout<<"class B funcN - INondelegation"<<endl;
}
virtual void funcP()
{
cout<<"class B funcP - INondelegation"<<endl;
}
virtual void nonfuncM();
virtual void nonfuncN();
virtual void nonfuncP();
};
B::B()
{
}
void B::nonfuncM()
{
cout<<"class B funcM INondelegation, no delegation"<<endl;
}
void B::nonfuncN()
{
cout<<"class B funcN INondelegation, no delegation"<<endl;
}
void B::nonfuncP()
{
cout<<"class B funcP INondelegation, no delegation"<<endl;
}
void trans(B& bt, void** pvv)
{
#if 1
*pvv = static_cast<A*>(&bt);
#else
*pvv = static_cast<INondelegation*>(&bt);
#endif
reinterpret_cast<IUnknown*>(*pvv)->funcM();
}
void main()
{
#if 1
// A a;
B b;
B* pp = &b;
IUnknown* pa = NULL;
trans(b, (void**)&pa);
// reinterpret_cast<IUnknown*>(pa)->funcM();
// pa->funcM();
#else
/*
B b;
INondelegation* pfb = &b;
IUnknown* pb = (IUnknown*)&b;
pb->funcM();
// pfb->nonfuncM();
*/
#endif
}
- COM聚合的简单模拟
- COM聚合的实现
- COM聚合的实现
- com 聚合的实现
- COM 的聚合和包容
- Com+编程:聚合的理解
- ATL 实现com的聚合
- COM聚合
- COM聚合
- COM聚合
- com聚合
- COM技术内幕中聚合的实现
- COM SDK 聚合组件的调试
- 简单的mongdb聚合查询
- <com原理>与<com内幕>的聚合实现部分。
- <com原理>与<com内幕>的聚合实现部分
- 聚合 包容 COM
- COM聚合(转)
- 好开心!又下雨了!
- 学黑客必去的网站“黑客基地”
- 重喝咖啡
- 学JAVA 吃馅饼
- 第一篇文章该写点什么好呢~
- COM聚合的简单模拟
- 怎么做需求分析
- 新雨
- SqlServer Convert 函数应用
- YouSendIt - GB级文件分发服务
- Superlove 包 很合适现在的女孩儿?
- 利用dl函数突破disable_functions执行命令
- PL/SQL用户指南与参考1
- Oracle开发专题之:分析函数(OVER)