[OT] Slimline C++ Class Q

May be off topic, but I’m trying to follow Juce style, so…

I made a very small class just to use as a common base/interface, but my compiler (GCC 3/4, Mac Xcode) doesn’t find all the symbols unless I put blank definitions in.

I would think that since the sub-classes implement the ‘real’ method, and the compiler should provide the constructor and destructor they would be OK blank? Why not? Class version that works below - it’s in a .h with header guards, if that matters.

Bruce

[code]class VC_EditView

{

public:
VC_EditView()
{
}

~VC_EditView()
{
}

	

virtual void fillInProps(PropertyPanel* ioPanel) = 0;

private:

};

[/code]

You haven’t presented what doesn’t work.

If your original version looked like this:

class VC_EditView
{
public:
   VC_EditView();
   ~VC_EditView();
 
   virtual void fillInProps(PropertyPanel* ioPanel) = 0;

private:
};

then your reason is that you’ve declared the functions but not defined them; the compiler will only create a default constructor if you’ve not declared one at all- once you’ve declared a function, you must define it (or present it as a pure virtual, as you have done with fillInProps()).

If, of course, your original version looked like this:

class VC_EditView
{
public:
   virtual void fillInProps(PropertyPanel* ioPanel) = 0;

private:
};

…and you still had the problem then i don’t know - the compiler should generate them automatically.

The first case. So that was it - I told the compiler I was going to provide that function then didn’t.

Thanks! The warnings were a bit un-communicative - because of mangled names I presume, so that’s good info. I feel like I need to make classes with the least typing - since it seems I need so many to be a good juce-citizen.

Bruce

Also, if you’re going to have pointers to VC_EditView you need to declare the destructor virtual, otherwise the non-abstract subclasses destructor won’t be called upon destruction.

I am, so thank you. That would have led to some debugging adventures.

Bruce