일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- relative path
- html object
- html charset
- html multimedia
- mac terminal command
- border-box
- #3차원배열
- hyperledger transaction
- #성적관리프로그램
- html video
- #CallByAddress
- #자바상속#자바이즈어#is~a
- html5 new tag
- #android activity
- #다차원포인터
- #2차원배열
- 하이퍼레저패브릭
- docker example
- html code
- #C++ has~a
- html youtube
- html plug-in
- html id
- 토큰경제
- #bubbleSort
- #1차원배열
- #JAVASCRIPT
- git flow
- #binary
- #C++ 연산자함수오버로딩
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 |