Repository navigation
Expand file tree
/
Copy pathclass object.cpp
More file actions
210 lines (181 loc) · 4.46 KB
/
Copy pathclass object.cpp
File metadata and controls
210 lines (181 loc) · 4.46 KB
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
// // in structure we can not hiding data
// we must use struct key word to declare variable
// all data in structure are public also there is not methods
// classes==structure +others
// and in class are by default private we have data hiding
// just only holding data then use strucure itherwise use class
// classes have methodes and properties
// both are public or private
// not use here struct key word with variable
//can create variable along with }
//sample
// class first{
// private: // only function that are declare in class they only can use it
// int a,b,c;
// public:
// int d,e;
// void setdata(int a1,int b1,int c1);//declaration // we can also impliment here fucntion
// void getdata(){ //implimentation
// cout<<"the values are "<<a <<b<<c<<d<<e;
// }
// };
// void first :: setdata(int a1,int b1,int c1){
// a=a1;
// b=b1;
// c=c1;
// }
// int main(){
// first neha;
// neha.setdata();
// neha.d=4;
// //neha.a=2;//give error bcz a is a private data thats why we can not directly access this
// cin>>neha.e;
// //cin>>neha.a; // cannot its private
// neha.getdata();
// }
//## NESTING OF MEMBER FUNCTION
// class binary{
// string s;
// public:
// void read(void);
// void chk_bin(void);
// void one(void);
// void display(void);
// };
// void binary:: read(void){
// cout<<"string";
// cin>>s;
// chk_bin(); // its call nesting of function we directly call like that if all fucntion are public or private both
// one();
// display();
// }
// void binary:: chk_bin(void){
// for(int i=0;i<s.length();i++){
// if(s.at(i)!='0' && s.at(i)!='1'){
// cout<<"not valid";
// exit(0);
// }
// }
// }
// void binary:: one(void){
// for(int i=0;i<s.length();i++){
// if(s.at(i)=='0')
// s.at(i)='1';
// else
// s.at(i)='0';
// }
// }
// void binary:: display(void) {
// for(int i=0;i<s.length();i++){
// cout<<s.at(i);
// }
// }
// int main(){
// binary b;
// b.read(); // you can only do this if all the function are public if they are
// // private then we cannot do this for this we have to du nesting of fucntion
// // b.chk_bin();
// // b.one();
// // b.display();
// }
// class book{
// string bookname;
// string authorname;
// int rate;
// int qty;
// public:
// void getdata(void);
// void displaydata(void);
// void calculate(void);
// };
// void book:: getdata(void){
// cout<<"you bookname";
// getline(cin,bookname);
// cout<<"your author name";
// getline(cin,authorname);
// cout<<"rate of book";
// cin>>rate;
// cout<<"how many book you want";
// cin>>qty;
// }
// void book:: displaydata(void){
// cout<<"you bookname";
// cout<<bookname<<endl;
// cout<<"your author name";
// cout<<authorname<<endl;
// cout<<"rate of book";
// cout<<rate<<endl;
// cout<<"how many book you want";
// cout<<qty;
// calculate();
// }
// void book:: calculate(void){
// int total_price=qty*rate;
// cout<<"your total price is";
// cout<<total_price;
// }
// int main(){
// book my;
// my.getdata();
// my.displaydata();
// }
//## memory allocation .......
// class shop{
// int itemid[100];
// int itemprice[100];
// int count;
// public:
// void setprice(void);
// void initcout(void){
// count=0;
// }
// void getprice(void);
// };
// void shop:: setprice(void){
// cout<< "id is" << endl;
// cin>>itemid[count];
// cout<< "itemprice" << endl;
// cin>>itemprice[count];
// count++;
// }
// void shop:: getprice(void){
// for(int i=0;i<count;i++){
// cout<< "itemid" <<itemid[i]<<"itemprice"<<itemprice[i];
// }
// }
// int main(){
// shop s;
// s.initcout();
// s.setprice();
// s.setprice();
// s.setprice();
// s.setprice();
// s.getprice();
// }
// class num{
// int a;
// int b;
// public:
// void getdata(void);
// void putdata(void);
// };
// void num:: getdata(void){
// cin>>a>>b;
// }
// void num:: putdata(void){
// cout<<a<<b;
// }
// int main(){
// num n,m;
// n.getdata();
// n.putdata();
// m.getdata();
// m.putdata();
// }