By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,760 Members | 1,644 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,760 IT Pros & Developers. It's quick & easy.

Error: "cannot instantiate abstract class"

P: n/a
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
Nov 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Andreas Poller wrote:
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

Nov 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.