Error: "cannot instantiate abstract class"

A

Andreas Poller

Hello,

I have the following problem:

I have a class deriving from ICustomTypeDescriptor:

public __gc class TPropertyBag : public ICustomTypeDescriptor
{

private: ...

public:
....
virtual String* GetClassName(){return
TypeDescriptor::GetClassName(this,true);} //[LINE 27]
....
};

------

When I try to instantiate it, I get the following compiler errors:

------ Build started: Project: QiCadApp, Configuration: Debug Win32
------

Compiling...

TCadInspector.cpp

d:\apps\TPropertyBag.h(27) : error C2039: 'GetClassNameA' : is not a
member of 'System::ComponentModel::TypeDescriptor'
TCadInspector.cpp(0) : see declaration of
'System::ComponentModel::TypeDescriptor'

d:\apps\TPropertyBag.h(27) : error C2660:
'TPropertyBag::GetClassNameA' : function does not take 2 arguments

TCadInspector.cpp(11) : error C2259: 'TPropertyBag' : cannot
instantiate abstract class
due to following members:
'System::String __gc *TPropertyBag::GetClassName(void)' : pure
virtual function was not defined
TCadInspector.cpp(0) : see declaration of
'TPropertyBag::GetClassName'

Build log was saved at "file://d:\apps\Debug\BuildLog.htm"
QiCadApp - 3 error(s), 0 warning(s)

---------

I don´t understand anything what the compiler tells me, because:

1. I have the Symbol "GetClassNameA" anywhere in my project
2. As you can see, I overrided the virtual function "virtual String*
GetClassName()" correctly

I can remove the error 2039 and 2660 when I change the line

virtual String* GetClassName(){return
TypeDescriptor::GetClassName(this,true);}
to
virtual String* GetClassName(){return NULL;}

The interesting thing is, that in another project it works without any
problems. I included the unit with this code to this new project and
got these errors. Maybe there is something wrong with the project
settings of this new project but I don`t know where to search.

I hope that anyone can help me,

Thanks

Andreas
 
C

Carl Daniel [VC++ MVP]

Andreas said:
Hello,

I have the following problem:

You've #included <windows.h> which defines a macro GetClassName.

A simple

#undef GetClassName after the #include should do the trick.

-cd
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top