I found found out that to extend a class I would have to do this:
class x : public extendsThis { // rest here
};
So, I create 2 classes, in two seperate files:
- particle.h -
class particle : public program {
};
- program.h -
class program {
particle* myParticle;
};
However, in the program class I wanted to have particle objects, which then again extend the program class.
This would however require me to have a include program.h in the particle class, and a particle.h include in the program class to let them know about each other. This however created some infinite loop that made me unable to compile.
Is there any way around this, or am I doing something wrong?
Yes, you can work around this. You can make a very simple class declaration.
In program.h:
class particle;
class program
{
particle *myParticle;
};
Keep in mind that you need to use a pointer to particle.