I changed some stuff around, and now I have this:
Code:
class GraphObj
{
public:
GraphObj(const string inputstr)
{
line = inputstr;
}
//virtual ~GraphObj() = 0;
virtual void draw(Image& img) = 0;
private:
string line;
};
And
Code:
class Line : public GraphObj
{
public:
Line(const string inputstr) : GraphObj(inputstr)
{
line = inputstr;
}
//~Line() : ~GraphObj()
//{
//}
void draw(Image& img)
{
// do stuff
}
private:
string line;
};
Two questions:
If I want to use inheritance, do I have to have the stuff in bold, or is it done automatically for me? (So I can delete it and the "line" variable will still be created / initialized)
Also, it gives me some warnings:
Code:
main.cpp:24: warning: ‘class GraphObj’ has virtual functions but non-virtual destructor
main.cpp:37: warning: ‘class Line’ has virtual functions but non-virtual destructor
I tried to add the destructor stuff in but I'm not sure if I'm doing it right (the stuff commented out), because it gives a bunch of nasty errors about linking...
I don't want to write a destructor for every one of my subclasses, but do I *have* to do it if I want to get rid of the warning?