PDA

View Full Version : Error creating subclasses



agerlach
24th May 2010, 22:27
Howdy, I think my problem is more of an issue with my understanding of C++ then of Qt, but I'm using Qt so I'll post my question here.

A little background on the problem... What I am try to do is implement a surface matching algorithm which can be trained on any 3D surface mesh. To train the algorithm a 2D histogram is generated for each vertex on the surface mesh and stored in a database. Surface matching is then performed by taking a new 3D surface mesh of the same object, randomly selecting a few vertices, calculating the 2D histogram for those vertices, and then comparing them to the 2D histograms that are stored in the database.

What I would like to do is setup a core class that contains all the methods that are required in both the training and matching phases, ie. calculating a 2D histogram, and then subclass that core class with a training and matching class. First off, is this the general approach I should be taking?

So I generated a class called siCore which works fine


class siCore :public QThread
{
Q_OBJECT
public:
friend class MainWindow;
siCore(MainWindow *gui);
void run();

signals:
void updateMainThreadStatus(QString statusLog);
void updateMainThreadProgress(int progValue);

MainWindow *appWindow;
};

I then generated class called siTrainer that inherits from siCore



#include "sicore.h"

class siTrainer : public siCore
{

public:
siTrainer();

};

but when I compile this simple example I get the following error:

'siCore' : no appropriate default constructor available - sitrainer.cpp

I'm sure it is something simple, but what am I doing wrong here?

Zlatomir
24th May 2010, 22:51
Define a constructor with no arguments...
And don't forget the class destructor, and make it virtual (for all base classes), like this:


class siCore {
public:
siCore(){...}
//...
virtual ~siCore(){//... actual cleaning of dynamic allocated resources
}
};

agerlach
25th May 2010, 13:49
Thanks, I knew it would be simple!