64,646
社区成员
发帖
与我相关
我的任务
分享
#include<iostream>
using namespace std;
class Book
{
private:
int qu;
int price;
public:
Book(int x)//构造函数的名字
{
qu=x;
}
int next(int x)
{
price=10*x;
return price;//直接返回,不要在这里输出
}
int get()
{
return qu;
}
} ;
int main()
{
int i;
Book A[5]={1,2,3,4,5}; //此处显示无法将int数据转化到Book
for(i=0;i<4;i++)
cout<<"the number is "<<A[i].next(i+1);
cin.get();
return 0;
}