Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

atlcom.h -- ATL::CComObject<Base>' : cannot instantiate abstract class

185 views
Skip to first unread message

Wesley T Perkins

unread,
Mar 24, 2005, 11:17:56 PM3/24/05
to
Hello,

I have a large project which worked fine under VS 7 but under VS 8 Beta I
get the error:

error C2259: 'ATL::CComObject<Base>' : cannot instantiate abstract class
C:\Program Files\Microsoft Visual Studio 8\VC\atlmfc\include\atlcom.h 1758


atlcom.h is an include file I need, but the error actually seems to be in
Microsoft's own code in that file The offending line is:
ATLTRY(p = new T1(pv))
Google shows that this problem is widespread, but I have never seen a
workaround.

Any ideas?

Thanks,
Wesley T Perkins
wes...@svgcomposer.com


template <class T1>
class CComCreator
{
public:
static HRESULT WINAPI CreateInstance(void* pv, REFIID riid, LPVOID* ppv)
{
ATLASSERT(ppv != NULL);
if (ppv == NULL)
return E_POINTER;
*ppv = NULL;
HRESULT hRes = E_OUTOFMEMORY;
T1* p = NULL;
ATLTRY(p = new T1(pv))
if (p != NULL)
{
p->SetVoid(pv);
p->InternalFinalConstructAddRef();
hRes = p->_AtlInitialConstruct();
if (SUCCEEDED(hRes))
hRes = p->FinalConstruct();
if (SUCCEEDED(hRes))
hRes = p->_AtlFinalConstruct();
p->InternalFinalConstructRelease();
if (hRes == S_OK)
hRes = p->QueryInterface(riid, ppv);
if (hRes != S_OK)
delete p;
}
return hRes;
}
};


Kim Gräsman

unread,
Mar 25, 2005, 8:35:56 AM3/25/05
to
Hi Wesley,

> I have a large project which worked fine under VS 7 but under VS 8 Beta I
> get the error:
>
> error C2259: 'ATL::CComObject<Base>' : cannot instantiate abstract class
> C:\Program Files\Microsoft Visual Studio 8\VC\atlmfc\include\atlcom.h 1758
>
> atlcom.h is an include file I need, but the error actually seems to be in
> Microsoft's own code in that file The offending line is:
> ATLTRY(p = new T1(pv))
> Google shows that this problem is widespread, but I have never seen a
> workaround.

Hmm, strange that it's a new error in VC8... Anyway, this is the symptom of your forgetting to implement a method in an interface.

Since ATL derives from your implementation class, when it attempts to instantiate said class, the compiler will see that there are still un-implemented pure virtual methods.

This error is usually followed by a diagnostic message telling you which methods have not been implemented -- look there for clues.

--
Best regards,
Kim Gräsman

0 new messages