main()関数で作った クラスBBのインスタンス y を class AA 内で呼び出して、クラスBBの関数を使いたいのですが、アドバイスよろしくお願いします。
C++
1#include <iostream> 2using namespace std; 3class BB{ 4 public: 5 int b(int n){ 6 return n*2; 7 } 8}; 9class AA{ 10 private: 11 int value=2; 12 public: 13 int a(){ 14 return y.b(value); 15 } 16}; 17int main(){ 18 AA x; 19 BB y; 20 cout<<x.a(); 21}
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/10/13 12:56 編集
2018/10/13 12:58
2018/10/13 13:02 編集
2018/10/13 13:03
2018/10/13 14:07
2018/10/13 14:13 編集
2018/10/21 10:48