> I take a component class & include the program.h file.
> So, if I place #include "program.h" inside of sound.h, suddenly program.h
> tells me Unknown type name 'Sound'
Do not include `program.h' in `Sound.h'
Sound.cpp makes use of `program', so it must include `program.h'
Sound.h makes no use, a forward declaration would suffice.
Read this article, specially point 4
http://www.cplusplus.com/forum/articles/10627/
Also, include is simply copy-paste. You may try to make your program build from a single file, declarations at the top, definitions at the bottom, and after that builds correctly, separate them to .h and .cpp
1 2 3 4 5
|
class Program;
class Sound{/**/};
class Program{/**/};
//member functions
|
@gunnerfunner:
class Graphics : private Program
, that means that `Graphics' has-a `Program', the relationship is backwards.
1 2 3
|
Graphics g;
Sound s;
Item i;
|
g, s and i have each one a `Program', a different `Program'. There is no relationship between g, s or i.
Hmm...
@OP: perhaps there is a bigger design issue. ¿what problem are you trying to solve?
you want the components to communicate between them, ¿what for?, ¿can't program manage all the communications?, ¿why do you need direct access to each component?