I'm trying to be able to instantiate 1 instance of C and any number of A and B. From there I want to be able to call C's addOne() function from inside of A or B and have it add 1 to the same variable "number" every time.
Is this possible to do without just re-writing the class as part of main()?
privatestatic C* _self;
static C* Instance()
if(!_self) _self = new C();
int number; //left it public like in your code
C::Instance() -> addOne();
Or you can just make usage of static variables and do not create instances at all:
1 2 3 4 5 6 7 8
staticint number = 0;