c++ – invalid new-expression of abstract class type
c++ – invalid new-expression of abstract class type
invalid new-expression of abstract class type box
There is nothing unclear about the error message. Your class box
has at least one member that is not implemented, which means it is abstract. You cannot instantiate an abstract class.
If this is a bug, fix your box class by implementing the missing member(s).
If its by design, derive from box, implement the missing member(s) and use the derived class.
for others scratching their heads, I came across this error because I had innapropriately const-qualified one of the arguments to a method in a base class, so the derived class member functions were not over-riding it. so make sure you dont have something like
class Base
{
public:
virtual void foo(int a, const int b) = 0;
}
class D: public Base
{
public:
void foo(int a, int b){};
}
c++ – invalid new-expression of abstract class type
If you use C++11, you can use the specifier override, and it will give you a compiler error if your arent correctly overriding an abstract method. You probably have a method that doesnt match exactly with an abstract method in the base class, so your arent actually overriding it.