BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Error: Pure virtual function called

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (ActiveX)
View previous topic :: View next topic  
Author Message
Evgeniy Balandin
Guest





PostPosted: Sun Oct 03, 2004 11:04 pm    Post subject: Error: Pure virtual function called Reply with quote



Hi!

I need to make inheritance of interfaces and to reuse implementation Com1 in
Com2.
At use of such implementation there is a error (Pure virtual function
called)
at attempt of a call of a method hello2 of the interface ICom2.
If to cause a method that is direct through the index on a class a call
hello2 works.
In what there can be a problem?

Please help.


ICom1Ptr pCom1;
ICom2Ptr pCom2;

pCom1 = new CCom1();
pCom1->hello(); // call method passed

pCom2 = new CCom2();
pCom2->hello(); // call method passed
pCom2->hello2(); // call method raised error: Pure virtual function called



// Implementation CCom1 and CCom2


#include <System.hpp>
#include "systobj.h"
#include "utilcls.h"

__interface ICom1;
typedef TComInterface<ICom1> ICom1Ptr;
typedef System::DelphiInterface<ICom1> _di_ICom1;
__interface INTERFACE_UUID("{DFF1F426-EBE9-471D-9D85-B7C2D589B958}") ICom1:
public IUnknown
{
public:
virtual void hello() = 0;
};

__interface ICom2;
typedef TComInterface<ICom2> ICom2Ptr;
typedef System::DelphiInterface<ICom2> _di_ICom2;
__interface INTERFACE_UUID("{19B2E6D7-EC5F-4B0A-81BF-AB107C06B69A}") ICom2:
public ICom1
{
public:
virtual void hello2() = 0;
};


template <class Itf>
class ICom1Impl : public TInterfacedObject, public Itf
{
public:
virtual HRESULT __stdcall QueryInterface(const GUID& IID, void **Obj)
{
return TInterfacedObject::QueryInterface(IID, Obj);
}
virtual ULONG __stdcall AddRef()
{
return TInterfacedObject::_AddRef();
}
virtual ULONG __stdcall Release()
{
return TInterfacedObject::_Release();
}
virtual void hello()
{
//............
}
};


template <class Itf>
//template <class Itf>
class ICom2Impl : public ICom1Impl<Itf>
{
public:
// Implement the IDerived methods here
virtual void hello2()
{
//............
}
};

typedef ICom1Impl<ICom1> CCom1;
typedef ICom2Impl<ICom2> CCom2;


Best regals, Evgeniy Balandin



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (ActiveX) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.