a**i 发帖数: 152 | 1 I have a class A, it has class B and a bunch of arrays a1, a2, ...
So the definition looks like:
class A
{
array a1;
array a2;
class C; // need to access a1, a2, ...
}
My question is: what is a good way for C to access a1 and a2? I can
certainly pass in A or a1 and a2, but this way looks odd to me.
| l*********s 发帖数: 5409 | | a***y 发帖数: 2803 | 3 class A
{
array a1;
array a2;
public:
friend class C; // need to access a1, a2, ...
}
-----------------------------------------------
如果是我,可能我会在class a里面包含一个class c的object
class C { ....};
class A {
array a1;
array a2;
C* c;
};
【在 a**i 的大作中提到】 : I have a class A, it has class B and a bunch of arrays a1, a2, ... : So the definition looks like: : class A : { : array a1; : array a2; : class C; // need to access a1, a2, ... : } : My question is: what is a good way for C to access a1 and a2? I can : certainly pass in A or a1 and a2, but this way looks odd to me.
|
|