#include<iostream>
using namespace std;
class book{
public:
book(int q,int p)
{qu=q;price=p;}
int accumulate()
{
return(qu*price);
}
private:
int qu,price;
};
int main()
{
book bo[5]={
book(1,10),
book(2,20),
book(3,30),
book(4,40),
book(5,50)};
cout<<"The accumulate of bo[0] is "<<bo[0].accumulate()<<endl;
cout<<"The accumulate of bo[1] is "<<bo[1].accumulate()<<endl;
cout<<"The accumulate of bo[2] is "<<bo[2].accumulate()<<endl;
cout<<"The accumulate of bo[3] is "<<bo[3].accumulate()<<endl;
cout<<"The accumulate of bo[4] is "<<bo[4].accumulate()<<endl;
return 0;
}
4.19
最新推荐文章于 2024-05-10 17:29:06 发布