-
linking objects
i was wondering if anybody could help me with the syntax for 4 classes to pass messages between each other, i can get it to compile but when i run the program the program crashes when it comes time to message pass, i have 4 classes and i am tring to link them through a 5th one, if anybody can help it would be greatly appreciated
-
Well in your case, put this-pointer from each 4 classes to be members of the 5th class. Then direct each function call to the proper object.
Crashing refers to pointer error. So I could quess that you're trying to call object via false pointer value. Hard to tell without knowing your class structure.
-
Could you elaborate on that. I have the same problem. This is how I did my code.
class A {int a;}
class B {int a; A *output[2];}
A a[2]; B b[2];
*b[0].output[0]=a[0];
*b[0].output[1]=a[1]; ...
b[0].output[0].a=1;
-
Try something like -
A a[2]; B b[2];
b[0].output[0]=&a[0];
b[0].output[1]=&a[1];
b[0].output[0]->a=1;