参照书本p89,例4.3
#include<iostream>
using namespace std;
class book{
public:
book(int a,int b)
{
qu=a;
price=b;
}
int get()
{
return (qu*price);
}
private:
int qu;
int price;
};
int main()
{
book b[5]={
book(1,10),
book(2,20),
book(3,30),
book(4,40),
book(5,50)
};
for(int i=0;i<5;i++)
cout<<b[i].get()<<endl;
system("pause");
return 0;
}