- #include<iostream>
- using namespace std;
- class book{
- public:
- book(int a)
- {
- qu=a;
- price=a*10;
- }
- void display();
- private:
- int qu;
- int price;
- };
- void book::display()
- {
- cout<<qu*price<<endl;
- }
- int main()
- {
- book books[5]={
- book(1),
- book(2),
- book(3),
- book(4),
- book(5)
- };
- for(int i=0;i<5;i++)
- {
- books[i].display();
- }
- return 0;
- }
4.20
最新推荐文章于 2025-04-20 23:03:47 发布