Forward declaration for base classes

I have a couple of my own Juce derived classes, button/slider/knob, i want them to have an additional base class (parent class?) that i wrote too. I can’t include the base classe’s header in all of them cause i get class re-declaration errors.

i have
PanelKnob.h/cpp
PanelSlider.h/cpp
PanelButton.h/cpp

and
PanelController.h/cpp (this is the base for all others)

if can’t include it in all other controller classes can i forward declare the class (though i don’t think this will work for the compiler). What other methods are there? all Panel* classes include <juce.h> and Knob, Slider and Button are based on some Juce classes, the Controller class isn’t.

Unless I’m missing your point, aren’t you just forgetting to put a conditional define in the header of your parent class?

Unless I’m missing your point, aren’t you just forgetting to put a conditional define in the header of your parent class?[/quote]

I think valley is right, try putting this preprocessor directives into each of your header file:

#ifndef _NAME_OF_YOUR_FILE_
#define _NAME_OF_YOUR_FILE_

// your #includes here
// your code here.......

#endif // end of the _NAME_OF_YOUR_FILE_

your not missing the point (that helped), but i didn’t forget i simply didn’t know that i had to do it. i always saw that across other code (juce source) but i nver figured out what is that for, now i know.

thanks.

It is because the directive #include literally copies the content of the file into the place of inclusion directive. And once you get 2 (or more) copies of the same file (same definitions etc.), the compiler complains…
Note also that there is also #pragma once directive in MSVC compiler (and some other compilers support it too) but is non-standard and therefore you might have problems with it when compiling in other compilers that don’t support it…
Y.