relating classes

Aloha...

In my current program I have a few classes which need to call methods from other classes (there are no circular dependencies (like A calls B.Method , B calls A.Method)...

but I am not sure of how to implement this relationship...
At the moment I made a pointer to the needed class a member of the first one and pass the address to the constructor...

Im not sure if it´s the best way of doing this.

Any suggestions?...

atm i have the following...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
class A{
//stuff
};

class B {
//stuff
B(A *a){pA = a;};
A *pA;
type funcA(){//dosomething on pA->method};
};

class C {
//stuff
A *pA;
B *pB;
//... do something with pA and pB...
};
hmmm...

well... if anyone is interested...

I add an wrapper-class which contains pointers to other classes, which -in turn- can be accessed via member functions...
Topic archived. No new replies allowed.