類A的定義在頭檔案a.h中,
class A {
public:
void Display() const {
cout<<"The argment is NULL"<<endl;
}
void Display(const char * str) const {
cout<<"The argment is "<<str<<endl;
}
void OtherFunc() {
}
};
main函式寫在mainApp.cpp檔案中,
int main(int argc,char * argv[])
{
A aA;
if (argc>1) {
aA.Display(argv[1]);
} else {
aA.Display();
}
cout<<sizeof(A)<<endl;
return 0;
}
class B {
public:
B(A& aA) { pA = &aA; }
void Func() {
cout<<"This is member function Func()"<<endl;
}
void NewFunc()
{
pA->OtherFunc();
}
private:
A * pA;
};
請問將B中的NewFunc函式以外聯的形式實作,b.h可以怎么寫?
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/103069.html
標籤:C++ 語言
上一篇:長度為m的陣列,取出其中任意n個元素組成子陣列,任倆個子陣列中元素最多不能超過2個
下一篇:為什么c會輸出11啊
