Any help is appriciated. I\'m working on a C++ factory pattern and i get this error.
1>c:\\users\\brian\\documents\\visual studio 2010\\projects\\cst276lab_3\\guitar.hpp
To fix the specific problem, you need to declare a destructor for ElectricGuitarComponentFactory
because you have declared the destructor of the base class as a pure virtual function. Why you have declared the base class destructor as pure virtual, I don't know; it really doesn't make any sense to do that. The destructor should be declared virtual, but not as pure virtual.
Also, the syntax you have used,
public: virtual ~GuitarComponentFactory() = 0 {}
is ill-formed. You cannot declare a pure virtual function and provide a definition for it in the class definition. If you want to provide a definition for a pure virtual function, you must do so outside of the class definition. The compiler you are using, Visual C++, is a bit lenient with respect to this rule.
class GuitarComponentFactory
{
public: virtual ~GuitarComponentFactory() = 0 {}
};
In your derived ElectricGuitarComponentFactory
you don't provide a destructor, hence it's still an abstract class.
ElectricGuitarComponentFactory inherits GuitarComponentFactory ....
When you inherit an abstract class (abstract = has pure virtual methods), then you need to override all those methods.
in GuitarComponentFactory you got 7 methods, and in ElectricGuitarComponentFactory you only declared 6.
You forgot to override the destructor.