일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- html charset
- 토큰경제
- docker example
- #1차원배열
- #성적관리프로그램
- mac terminal command
- #다차원포인터
- html multimedia
- #android activity
- html video
- #bubbleSort
- html code
- hyperledger transaction
- border-box
- html object
- html youtube
- html5 new tag
- relative path
- #자바상속#자바이즈어#is~a
- #JAVASCRIPT
- #C++ 연산자함수오버로딩
- html plug-in
- html id
- #3차원배열
- #C++ has~a
- #binary
- #2차원배열
- #CallByAddress
- 하이퍼레저패브릭
- git flow
Archives
- Today
- Total
A sentimental robot
C++ passing reference to pointer 본문
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 |
#include<iostream>
#include<cstdlib>
#include"input.h"
#include"operators.h"
#include"disp.h"
using namespace std;
class Calculation{
int *a;
int*b;
char *c;
float *res;
public : Calculation(){
a=new int;
b=new int;
c=new char;
res=new float;
}
void cac(){
input(*a,b,&c);
*res=operators(a,b,c);
disp(res);
}
};
void main(){
Calculation *ca = new Calculation;
ca->cac();
delete ca;
ca=NULL; }
|
cs |
// input.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 |
#include<iostream>
using namespace std;
void input(int &a, int *&b, char **c){
cout << "숫자 1 입력 :";
cin >> a;
cout << "연산자 입력 :";
cin >> **c;
cout << "숫자 2 입력 :" ;
cin >> *b;
} |
cs |
// operators.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 |
#include<iostream>
using namespace std;
float operators(int *&a, int *&b ,char *&c){
float res;
switch(*c){
case '+': res= (float)*a+*b; break;
case '-': res=(float)*a-*b; break;
case '*': res=(float)*a * *b; break;
case '/':res=(float)*a / *b ; break;
default: cout << "wrong input"; break;
}
return res;
} |
cs |
// disp.h
1
2
3
4
5
6
7 |
#include<iostream>
using namespace std;
void disp(float *&res){
cout << *res<<endl;
} |
cs |