main
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 |
#include<iostream>
using namespace std;
#include "oper.h"
int main() {
cal *c = new cal;
c->input();
switch (c->getop()) {
case '+': c->setsum(); break;
case '-': c->setsuu(); break;
case '*': c->setmul(); break;
case '/': c->setdiv(); break;
}
c->print();
delete c;
}
|
cs |
oper
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 |
#include<iostream>
#include "oper.h "
using namespace std;
cal::cal() {
a = new int;
b = new int;
op = new char;
opp = new float;
}
cal:: ~cal() {
delete a;
delete b;
delete op;
delete opp;
}
cal::cal(cal &cal) {
a = new int;
b = new int;
op = new char;
opp = new float;
*(this->a) = *(cal.a);
*(this->b) = *(cal.b);
*(this->op) = *(cal.op);
*(this->opp) = *(cal.opp);
}
void cal::input() {
cout << "두 수를 입력해 주세요";
cin >> *a >> *b;
cout << "+,-,/,*중 선택하시오";
cin >> *op;
}
void cal::setmul() {
*opp= (*a) * (*b);
}
int cal:: getmul() {
return *opp;
}
void cal::setsum() {
*opp = (*a) + (*b);
}
int cal::getsum() {
return *opp;
}
void cal::setsuu() {
*opp = (*a) - (*b);
}
int cal::getsuu() {
return *opp;
}
void cal::setdiv() {
*opp = (float)*a / *b;
}
float cal::getdiv() {
return *opp;
}
void cal::print() {
cout << *opp;
}
char cal:: getop() {
return *op;
}
|
cs |
oper.h
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 |
#pragma once
#include "oper.h"
class cal {
private:
int *a;
int *b;
char *op;
float *opp = 0;
public:
// 생성자
cal();
// 소멸자
~cal();
// 복사 생성자
cal(cal &c);
// 함수선언
void input();
void setsum();
int getsum();
void setmul();
int getmul();
void setsuu();
int getsuu();
void setdiv();
float getdiv();
void print();
char getop();
};
|
cs |