質問編集履歴

1

コードを追加しました。

2016/01/24 13:00

投稿

saito.kaz
saito.kaz

スコア76

test CHANGED
File without changes
test CHANGED
@@ -32,18 +32,426 @@
32
32
 
33
33
  <Sales.h>
34
34
 
35
+ #include <string.h>
36
+
37
+ #include "Worker.h"
38
+
39
+
40
+
41
+ class Sales:public Worker{
42
+
43
+ public:
44
+
45
+ double profit;
46
+
47
+ char* client;
48
+
49
+ std::string addtionalInfo;
50
+
51
+ Sales();
52
+
53
+ Sales(double profit, char* client, std::string addtionalInfo, int number, char* name, double salary, bool i, char* plan, std::string pInfo);
54
+
55
+ Sales(const Sales &obj);
56
+
57
+ ~Sales();
58
+
59
+ void ShowData(Sales s1);
60
+
61
+ };
62
+
35
63
  <Sales.cpp>
36
64
 
65
+ #include <iostream>
66
+
67
+ #include <string.h>
68
+
69
+ #include "Sales.h"
70
+
71
+
72
+
73
+ using namespace std;
74
+
75
+
76
+
77
+ Sales::Sales(double profit, char* client, std::string addtionalInfo, int number, char* name, double salary, bool i, char* plan, std::string pInfo):Worker(number, name, salary, i, plan, pInfo){
78
+
79
+ this->profit = profit;
80
+
81
+ this->client = new char[100];
82
+
83
+ strcpy(this->client, client);
84
+
85
+ this->addtionalInfo = addtionalInfo;
86
+
87
+ }
88
+
89
+
90
+
91
+ Sales::Sales(const Sales &obj){
92
+
93
+ client = new char[100];
94
+
95
+ strcpy(client,obj.name);
96
+
97
+ this->profit =obj.profit;
98
+
99
+ this->addtionalInfo=obj.addtionalInfo;
100
+
101
+ }
102
+
103
+
104
+
105
+ Sales::~Sales(){
106
+
107
+ }
108
+
109
+
110
+
111
+ Sales::Sales():Worker(){
112
+
113
+ this->profit = 100;
114
+
115
+ this->client = new char[100];
116
+
117
+ strcpy(this->client, "Undifined_client");
118
+
119
+ this->addtionalInfo="undifined_additionalInfo";
120
+
121
+ }
122
+
123
+
124
+
125
+ void Sales::ShowData(Sales s1){
126
+
127
+ cout << "s1.name = " << s1.name << "\n";
128
+
129
+ cout << "s1.pInfo = " << s1.pInfo << "\n";
130
+
131
+ cout << "s1.profit = " << s1.profit << "\n";
132
+
133
+ cout << "s1.client = " << s1.client << "\n";
134
+
135
+ cout << " s1.addtionalInfo = " << s1.addtionalInfo << "\n";
136
+
137
+ cout << " s1.addtionalInfo " << s1.addtionalInfo << "\n";
138
+
139
+ }
140
+
141
+
142
+
143
+ int main(){
144
+
145
+ Sales s1;
146
+
147
+ return 0;
148
+
149
+ }
150
+
151
+
152
+
37
153
  <Worker.h>
38
154
 
155
+ #include <string.h>
156
+
157
+ #include "Phone.h"
158
+
159
+
160
+
161
+ class Worker{
162
+
163
+ public:
164
+
165
+ int number;
166
+
167
+ char* name;
168
+
169
+ double salary;
170
+
171
+ Phone phone;
172
+
173
+ Worker();
174
+
175
+ Worker(int number, char* name, double salary, bool i, char* plan, std::string pInfo);
176
+
177
+ Worker(const Worker &obj);
178
+
179
+ ~Worker();
180
+
181
+ };
182
+
39
183
  <Worker.cpp>
40
184
 
185
+ #include <iostream>
186
+
187
+ #include "Worker.h"
188
+
189
+
190
+
191
+ using namespace std;
192
+
193
+
194
+
195
+ Worker::Worker(){
196
+
197
+ name = new char[80];
198
+
199
+ strcpy(name, "undifined in Worker con");
200
+
201
+ number = 0;
202
+
203
+ salary = 0;
204
+
205
+ }
206
+
207
+
208
+
209
+ Worker::Worker(int number, char* name, double salary,bool i, char* plan, string pInfo):phone(i ,plan ,pInfo){
210
+
211
+ cout<< " This is Constructor called Worker(int number, char* name, double salary):Phone(bool i, char* plan, string pInfo) " << "\n";
212
+
213
+ this->number = number;
214
+
215
+ this->name = new char[80];
216
+
217
+ strcpy(this->name, name);
218
+
219
+ this->salary = salary;
220
+
221
+ }
222
+
223
+
224
+
225
+ Worker::Worker(const Worker &obj){
226
+
227
+ name = new char[80];
228
+
229
+ strcpy(name,obj.name);
230
+
231
+ this->number =obj.number;
232
+
233
+ this->salary = obj.salary;
234
+
235
+ };
236
+
237
+
238
+
239
+ Worker::~Worker(){
240
+
241
+ delete[] name;
242
+
243
+ }
244
+
245
+
246
+
247
+
248
+
249
+
250
+
251
+
252
+
253
+ /*
254
+
255
+ int main(){
256
+
257
+ Worker w1;
258
+
259
+ strcpy(w1.name,"Takayuki"); //Worker::Worker(int number, char* name, double salary,bool i, char* plan, string pInfo):
260
+
261
+ w1.number =10;
262
+
263
+ w1.salary = 200;
264
+
265
+ ShowData(w1);
266
+
267
+ //Worker::Worker(int number, char* name, double salary,bool i, char* plan, string pInfo):
268
+
269
+ Worker w2(1000, "name_w2", 1000, false, "plan_w2", "pInfo_w2");
270
+
271
+ ShowData(w2);
272
+
273
+
274
+
275
+
276
+
277
+ return 0;
278
+
279
+ }
280
+
281
+ */
282
+
41
283
  <Worker.h>
42
284
 
285
+ #include <string.h>
286
+
287
+ #include "Phone.h"
288
+
289
+
290
+
291
+ class Worker{
292
+
293
+ public:
294
+
295
+ int number;
296
+
297
+ char* name;
298
+
299
+ double salary;
300
+
301
+ Phone phone;
302
+
303
+ Worker();
304
+
305
+ Worker(int number, char* name, double salary, bool i, char* plan, std::string pInfo);
306
+
307
+ Worker(const Worker &obj);
308
+
309
+ ~Worker();
310
+
311
+ };
312
+
43
313
  <Phone.cpp>
44
314
 
315
+ #include <iostream>
316
+
317
+ #include <string.h>
318
+
319
+ #include "Phone.h"
320
+
321
+
322
+
323
+ using namespace std;
324
+
325
+
326
+
327
+ Phone::Phone(){
328
+
329
+ plan = new char[100];
330
+
331
+ this->i = false;
332
+
333
+ strcpy(this->plan, "normal");
334
+
335
+ this->pInfo = "nokia";
336
+
337
+ }
338
+
339
+
340
+
341
+ Phone::Phone(bool i, char* plan, string pInfo){
342
+
343
+ this->plan = new char[100];
344
+
345
+ this->i = i;
346
+
347
+ strcpy(this->plan, plan);
348
+
349
+ this->pInfo = "nokia";
350
+
351
+ }
352
+
353
+
354
+
355
+
356
+
357
+ Phone::~Phone(){
358
+
359
+ delete[] plan;
360
+
361
+ }
362
+
363
+
364
+
365
+
366
+
367
+ void Phone::ShowPhone(){
368
+
369
+ cout << " i = " << this->i << "\n";
370
+
371
+ cout << " plan = " << this->plan <<"\n";
372
+
373
+ cout << " pInfo = " << this->pInfo <<"\n";
374
+
375
+ }
376
+
377
+
378
+
379
+ void Phone::ShowData(){
380
+
381
+ }
382
+
383
+
384
+
385
+ /*
386
+
387
+ int main(){
388
+
389
+ Phone p1;
390
+
391
+ Phone p2(false, "p2","noraml2");
392
+
393
+ Phone p3(false, "p3","noraml3");
394
+
395
+ cout << "----------p2.ShowPhone();-------------------" << "\n";
396
+
397
+ p2.ShowPhone();
398
+
399
+ cout << "----------p3.ShowPhone();-------------------" << "\n";
400
+
401
+ p3.ShowPhone();
402
+
403
+ cout << "-----------------------------" << "\n";
404
+
405
+
406
+
407
+ p1.i = false;
408
+
409
+ strcpy(p1.plan,"normal");
410
+
411
+ p1.pInfo = "nokia";
412
+
413
+ p1.ShowPhone();
414
+
415
+ cout << "-----------------------------" << "\n";
416
+
417
+ p2.ShowData();
418
+
419
+
420
+
421
+ return 0;
422
+
423
+ }
424
+
425
+ */
426
+
45
427
  <Phone.h>
46
428
 
429
+ #include <string.h>
430
+
431
+
432
+
433
+ class Phone{
434
+
435
+ public:
436
+
437
+ Phone();
438
+
439
+ Phone(bool i, char* plan, std::string pInfo);
440
+
441
+ ~Phone();
442
+
443
+ bool i;
444
+
445
+ char* plan;
446
+
447
+ std::string pInfo;
448
+
449
+ void ShowPhone();
450
+
451
+ virtual void ShowData();
452
+
453
+ };
454
+
47
455
  ```
48
456
 
49
457