#include
using namespace std;

class B
{
};
class C
{
public:
    C(B b1):b(b1){}
    ~C(){}
private:
    B&    b;
};
class A
{
public:
    A():b(),c(b){}
    ~A(){}
private:
    B  b;
    C  c;
};

int main(int argc,char* argv[])
{
    A  a;

    return 0;
}
+++++++++++++++++++++++++++++++++++++++++++
Class C 中的私有成員 b,為reference型態,必須使用建構元指定參考目標。
Class A 中利用 私有成員 b,當作C的建構參數。
 以上是強者我同學教我的,看來我在C++上的功力還是太淺了。
arrow
arrow
    全站熱搜

    rangerll 發表在 痞客邦 留言(0) 人氣()