Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- 코딩
- 사물인터넷
- 개발자
- 개인프로젝트
- java정리
- 프로그래머스
- 프로그램
- Python
- 빅데이터
- Project
- 풀스택프레임워크
- 이웃한 칸
- 백준
- SNS
- 자바
- 개발
- 코딩독학
- 모의 주식
- java
- backend
- 자바독학
- 자바정리
- 프로그래밍
- 주가예측
- C++
- 코테
- frontend
- 코딩테스트
- 코스닥
- Reflex
Archives
- Today
- Total
Creative Code
swap2(template 함수) 본문
※main.cpp파일
#include <iostream>
#include "swap.h"
int main() {
int i = 100, j = 200;
swap(i,j);
std::cout<<"i : " << i << ", j : " << j << std::endl;
double d = 1.1, f= 2.2;
swap(d,f);
std::cout << "d : " << d << ", f : " << f << std::endl;
return 0;
}
※swap.h파일
#ifndef SWAP_H
#define SWAP_H
template <typename T>
void swap(T &ra, T &rb) { // template함수
T tmp = ra;
ra = rb;
rb = tmp;
}
#endif
'C++ Programming' 카테고리의 다른 글
genderRatio.cpp(static_cast) (0) | 2023.09.08 |
---|---|
safeArray4(try-throw-catch) (0) | 2023.09.08 |
boundArray2(template사용) (0) | 2023.09.08 |
safeArray3(template 사용) (0) | 2023.09.08 |
queue4(template사용) (0) | 2023.09.08 |