#include<iostream>
using namespace std;
class shop{
int id;
float price;
public:
void setdata( int a, float b)
{
id=a;
price=b;
}
void showdata(void){
cout<<"Id of the item is:"<<id<<endl;
cout<<"Price of item is :"<<price<<endl;
}
};
int main(){
int size=3;
shop *ptr= new shop[size];
shop *tempptr=ptr;
int p,i;
float q;
for ( i = 0; i <size; i++)
{
/* code */
cout<<"Enter the id of item"<<i+1<<endl;
cin>>p;
cout<<"Enter the price of item"<<i+1<<endl;
cin>>q;
ptr->setdata(p,q);
ptr++;
}
for ( i = 0; i <size; i++)
{
/* code */
cout<<"The item no"<<i+1;
tempptr->showdata();
tempptr++;
}
return 0;
}
0 Comments