-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathobject_memory_allotation.cpp
More file actions
45 lines (35 loc) · 967 Bytes
/
object_memory_allotation.cpp
File metadata and controls
45 lines (35 loc) · 967 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
44
45
/**************This is the code for shop to enter the id and price of the items*****************/
#include <iostream>
using namespace std;
class Shop{
int itemID[100];
int itemPrice[100];
int counter;
// all defult in class is private //
public:
int initCounter(void){ counter = 0;} // we can write this function outside the class
void setprice(void);
void displayprice(void);
};
void Shop :: setprice(void){
cout<<"Enter the ID of your item no "<< counter +1<<endl;
cin>>itemID[counter];
cout<<"Enter the Price of your item "<<endl;
cin>> itemPrice[counter];
counter++;
}
void Shop :: displayprice (void){
for (int i = 0; i < counter; i++)
{
cout<<"The Price of item with ID "<<itemID[i]<<" is "<<itemPrice[i]<<endl;
}
}
int main(){
Shop Mall;
Mall.initCounter();
Mall.setprice();
Mall.setprice();
Mall.setprice();
Mall.displayprice();
return 0;
}