-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharray_of_cobjects.c++
97 lines (48 loc) · 1.08 KB
/
array_of_cobjects.c++
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#include <iostream>
#include <string>
using namespace std;
// class laptop {
// public:
// int ram;
// public:
// void r (int ram) {
// cout << " The ram is :- " << ram << endl;
// }
// };
// int main() {
// laptop asus[5];
// for (int i = 0; i < 5; i++)
// {
// cout << "This is object :- " << i+1;
// asus->r(1024*i);
// }
// return 0;
// }
class books {
public:
string title;
float price;
public:
void getdata();
void putdata();
};
void books::getdata() {
cout << "Title :- "; cin >> title;
cout << "Price :- "; cin >> price;
}
void books::putdata() {
cout << "Title :- " << title << " && Price" << price << endl;
const int size = 5;
}
int main() {
books book[size];
for(int i=0; i <book.size; i++) {
cout << "Enter details of book " << (i+1) << endl;
book[i].getdata();
}
for(int i=0; i<book.size; i++) {
cout << "Book " << (i+1) << endl;
book[i].putdata();
}
return 0;
}