?????????????????????????COM??????????????????????????????????????COM?·???????????????????????

 

#pragma once
class IExtensibleObject
{
public:
virtual void* Dynamic_Cast(const char* str)=0;
virtual void AddRef()=0;
virtual void Release()=0;
};
class IFastString:public IExtensibleObject
{
public:
virtual int Length(void)=0;
virtual int Find(const char* str)=0;
};
class FastString:public IFastString
{
public:
FastString(const char* str=NULL);
virtual void* Dynamic_Cast(const char* str);
virtual void AddRef() ;
virtual void Release();
virtual int Length();
virtual int Find(const char* str);
~FastString();
private:
char* m_str;
int len;
int m_cPtrs;//???ü???
};
//????????
extern "C" __declspec(dllimport) IFastString*  CreateFastString(const char* psz);

?????????COM?????????????????????????????????
????1??????????????????????????????????????????????????????????????/?????????????????
????2??????????ó???????????????FastString????????FastString?????????????????????????FastString????????IFastString???????????????DLL??FastString?????С??????????????????е?????????????DLL?д??????
????3?????????FastString????????????????????delete??CreateFastString????????????????COM??????????FastString?????????????????????в???????????????????????????????????????????????????????????????????????ü???????????FastString??
????4????????????Dynamic_Cast??
????RTTI???????????????????????????????????????RTTI?????????е???????????“??????????????????????????????”???????????????????в???????????????????????????麯????????????????????麯?????鷽?????е?λ????????????е??????????????е??????棬????2???????????????鷽?????鷽?????е?λ???????????????????????????????virtual??????public???????????virtual???????鷽?????鷽?????е?λ?ú??鷽??????????????£?????????????????????鷽???С?
????????????????????ü????????????????????????????????????????????е?????????
????5??????????????????棬????????????????
???????????????????м?????????????鷽?????е????????仯???°汾??DLL??????????????????????????????????????????????????DLL??????????????????£?????????????????????????
?????????????????????DLL????????????£?
????COM?????????????????????DLL????new????????????????ü???????????????????????????COM????COM???????????????仯???????????????????????????????????????鷽?????е?λ?ò???????????????????????????????????????
?????????????????????virtual?????????????????????????????????????????????FastString?????????????FastString???????????????????????????????len??κ????Length????????????????3????汾????????????????DLL???????????????ж???OK?????????ò???????κ?????????????FastString????????????????????????DEMO????????????£?????????????
???????????????????????COM??????????????C++??