C++ 初学者。。。求解 missing storage-class or type specifiers
#include<iostream.h>classA{public:A():son1(x),son2(y){cout<<"chenggong"<<x*y<<endl;}p...
#include <iostream.h>
class A
{
public:
A():son1(x),son2(y) {cout<<"chenggong"<<x*y<<endl;}
private:
B son1;
C son2;
};
class B
{
public:
B() {a=9; cout<<"bbbbbbb"<<endl;}
private:
int a;
};
class C
{
public:
C() {b=8; cout<<"ccccccc"<<endl;}
private:
int b;
};
void main()
{
A data1;
} 展开
class A
{
public:
A():son1(x),son2(y) {cout<<"chenggong"<<x*y<<endl;}
private:
B son1;
C son2;
};
class B
{
public:
B() {a=9; cout<<"bbbbbbb"<<endl;}
private:
int a;
};
class C
{
public:
C() {b=8; cout<<"ccccccc"<<endl;}
private:
int b;
};
void main()
{
A data1;
} 展开
2个回答
展开全部
已改,看注释
#include <iostream>
using namespace std;
class B
{
public:
B() {a=9; cout<<"bbbbbbb"<<endl;}
int getA(){return a;} //返回私有成员a
private:
int a;
};
class C
{
public:
C() {b=8; cout<<"ccccccc"<<endl;}
int getB(){return b;} //返回私有成员b
private:
int b;
};
class A //A类放B、C类后面
{
public:
A(B x, C y):son1(x),son2(y) {cout<<"chenggong"<<x.getA()*y.getB()<<endl;}
private:
B son1;
C son2;
};
void main()
{
B b;
C c;
A data1(b, c); //传B、C类对象
}
#include <iostream>
using namespace std;
class B
{
public:
B() {a=9; cout<<"bbbbbbb"<<endl;}
int getA(){return a;} //返回私有成员a
private:
int a;
};
class C
{
public:
C() {b=8; cout<<"ccccccc"<<endl;}
int getB(){return b;} //返回私有成员b
private:
int b;
};
class A //A类放B、C类后面
{
public:
A(B x, C y):son1(x),son2(y) {cout<<"chenggong"<<x.getA()*y.getB()<<endl;}
private:
B son1;
C son2;
};
void main()
{
B b;
C c;
A data1(b, c); //传B、C类对象
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询