由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - A question about sharing data inside a C++ class
相关主题
一个java class downcast 的问题C++ question
a simple question一道Microsoft的面试题
请教改numpy array的dtypeIf using C++, please avoid the use of STL for these questio (转载)
C++ OO approach to use multi-dim array for HPCa weak c question, how to pass an array into a function?
[求教大虾]关于C++编译期变量和运行期变量的区别,总是有疑惑这段 C++ 怎么改才能编译?
C++求助: New/Delete in Multidimensioned arrayC++ 的 问题
How to return an array in a C++ function?C++ linking 弱问 (one file)
为什么在overloading中,friend <<不能读取private值呢?C++ array new一问
相关话题的讨论汇总
话题: class话题: a1话题: a2话题: array话题: c++
进入Programming版参与讨论
1 (共1页)
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
2
make it friendly
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.

1 (共1页)
进入Programming版参与讨论
相关主题
C++ array new一问[求教大虾]关于C++编译期变量和运行期变量的区别,总是有疑惑
[合集] A question about multidimensional arrays in C++!!C++求助: New/Delete in Multidimensioned array
请问如何把初始化一个const 的vector (or array) in a class?How to return an array in a C++ function?
问几个C++的题为什么在overloading中,friend <<不能读取private值呢?
一个java class downcast 的问题C++ question
a simple question一道Microsoft的面试题
请教改numpy array的dtypeIf using C++, please avoid the use of STL for these questio (转载)
C++ OO approach to use multi-dim array for HPCa weak c question, how to pass an array into a function?
相关话题的讨论汇总
话题: class话题: a1话题: a2话题: array话题: c++