-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path30_oops.cpp
More file actions
43 lines (39 loc) · 712 Bytes
/
30_oops.cpp
File metadata and controls
43 lines (39 loc) · 712 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include<iostream>
using namespace std;
class shop {
int id;
float price;
public:
void setdata(int a,float b){
id=a;
price=b;
}
void getdata(void){
cout<<"code of this item is"<<" "<<id<<endl;
cout<<"price of this item is"<<" "<<price<<endl;
}
};
int main(){
int size=3;
// int *p=&size;
//int *p=new int[34];
//general store
//veggies
//hardware
shop *p=new shop[size];
shop *pTemp=p;
int i,j;
float pr;
for(j=0;j<size;j++){
cout<<"enter the price and id of the item"<<j+1<<endl;
cin>>i>>pr;
p->setdata(i,pr);
p++;
}
for(j=0;j<size;j++){
cout<<"Item no"<<j+1<<endl;
pTemp->getdata();
pTemp++;
}
return 0;
}