Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7956 Discussions

parameter of abstract class type "type" is not allowed:

kinderchocolate
Beginner
1,710 Views
Hi,

I encounter an error when compiling "parameter of abstract class type "type" is not allowed", as described in http://software.intel.com/en-us/articles/cdiag646/. Does anybody know why and how to fix it?

Thanks,
0 Kudos
4 Replies
JenniferJ
Moderator
1,710 Views
Please paste some code snippet here. thanks!

Jennifer

0 Kudos
Judith_W_Intel
Employee
1,710 Views
The problem is you are trying to declare a parameter that has the type of an abstract base class.

Abstract classes are designed to be only interfaces to real classes because they have one or
more pure virtual functions, i.e.:

class abstract {
virtual void foo() = 0; // pure virtual function since it is declared with = 0
};

void foo(abstract); // not allowed since the class is abstract

The workaround would be to only use pointers or references to the abstractclass as parameters, or change
the type to a non-abstract class that is derived from the abstract class or change the class so it
is no longer abstract, i.e. define the virtual functions instead of declaring them pure virtual.

Judy

0 Kudos
Om_S_Intel
Employee
1,710 Views

I created a knowledge base article using content of this issue. The article is available at http://software.intel.com/en-us/articles/abstract-class-type-not-allowed-as-a-type-for-parameter/.
0 Kudos
kinderchocolate
Beginner
1,710 Views
Thank You, the information is very helpful.
0 Kudos
Reply