<pre name="code" class="cpp">#include<iostream>
using namespace std;
class book
{
public:
book(int q,int p)
{
qu=q;
price=p;
}
void show()
{
cout<<qu*price<<endl;
}
private:
int qu,price;
};
int main()
{
book b[5]={
book(1,10),
book(2,20),
book(3,30),
book(4,40),
book(5,50)
};
b[0].show();
b[1].show();
b[2].show();
b[3].show();
b[4].show();
return 0;
}
</pre><pre name="code" class="cpp">
</pre><pre name="code" class="cpp">
</pre><pre name="code" class="cpp"><pre name="code" class="cpp">#include<iostream>
using namespace std;
class book
{
public:
book(int q,int p)
{
qu=q;
price=p;
}
void show()
{
cout<<qu*price<<endl;
}
private:
int qu,price;
};
int main()
{
book b[5]={
book(1,10),
book(2,20),
book(3,30),
book(4,40),
book(5,50)
};
book *j=b;
for( int i=1;i<=5;i++)
{
j[5-i].show();
}
return 0;
}