#include<iostream>
using namespace std;
class book{
public:
book(int q,int p)
{qu=q;
price=p;
}
friend void opera(book *p);
private:
int qu;
int price;
};
void opera(book *p)
{int i=0;
for(i=0;i<5;i++)
cout<<"b"<<5-i<<"="<<p[4-i].qu*p[4-i].price<<endl;
}
int main()
{book b[5]={book(1,10),book(2,20),book(3,30),book(4,40),book(5,50)};
cout<<"以相反顺序输出的值依次为:"<<endl;
opera(b);
return 0;
}
程序运行的结果为: