M
mosfet
Hi,
I have a question regarding derived class, let' say I have a base class
class PimItem
// A MS COM interface : for people who don't know com it's an interface
struct IDispatch
{
...
};
// Smart COM pointers(interface)
// IContact derives from IDispatch
typedef CComQIPtr<IDispatch> IDispatchPtr;
typedef CComQIPtr<IContact,&__uuidof(IContact)> IContactPtr;
class PimItem
{
public:
PimItem(CComQIPtr<IDispatch> pIItem) {m_pIItem = pIItem};
virtual ~PimItem();
protected:
CComQIPtr<IDispatch> m_pIItem; // Smart pointer pointing to a COM interface
}
class Contact : public PimItem
{
public:
void set_Foo(...) { static_cast<IContactPtr> (m_pIItem)->set_Foo() }
void set_Fire(...) {static_cast<IContactPtr> (m_pIItem)->set_Fire() }
protected:
};
As you can see in the contact class ,everytime I want to access a
function I need to cast my base pointer to my derived base.
In this case wouln'd be easier to remove m_pIItem inside base class and
directly store the right pointer type inside my derived one ?
I have a question regarding derived class, let' say I have a base class
class PimItem
// A MS COM interface : for people who don't know com it's an interface
struct IDispatch
{
...
};
// Smart COM pointers(interface)
// IContact derives from IDispatch
typedef CComQIPtr<IDispatch> IDispatchPtr;
typedef CComQIPtr<IContact,&__uuidof(IContact)> IContactPtr;
class PimItem
{
public:
PimItem(CComQIPtr<IDispatch> pIItem) {m_pIItem = pIItem};
virtual ~PimItem();
protected:
CComQIPtr<IDispatch> m_pIItem; // Smart pointer pointing to a COM interface
}
class Contact : public PimItem
{
public:
void set_Foo(...) { static_cast<IContactPtr> (m_pIItem)->set_Foo() }
void set_Fire(...) {static_cast<IContactPtr> (m_pIItem)->set_Fire() }
protected:
};
As you can see in the contact class ,everytime I want to access a
function I need to cast my base pointer to my derived base.
In this case wouln'd be easier to remove m_pIItem inside base class and
directly store the right pointer type inside my derived one ?