How We Coding

- 변수를 생성과 동시에 초기화 하는 방법 추가.


1
2
3
4
5
int a = 5;
int a(5);
 
int a=2, b=3;
int a(2), b(3);
cs


>> 모든 자료형에 적용 가능.

>> 배열은 초기화 방법이 다르므로 이런식으로는 불가능



- for 문의 초기식에서 변수 선언 가능


1
2
for(int i=0; i<n; i++)
    scanf("%d"&k);
cs


>> 여기서 i 의 스코프(scope)는 해당 for 문의 안쪽이 된다.



- bool 타입의 자료형 추가.


1
2
bool isTrue = true;
bool isFalse = false;
cs



- 형변환(type casting) 의 추가.


1
2
3
4
5
double d = 3.14;
int n = (int)d;
 
double f = 3.141592;
int k = static_cast<int>(f);
cs


>> static_cast<자료형>(값) 의 형태를 가지고 있다.


>> 용도는 추후 포스팅..



- c 언어의 헤더파일 사용방법


1
2
3
4
5
#include <stdio.h> // C 
#include <stdlib.h> // C
 
#include <cstdio> // C++
#include <cstdlib> // C++
cs


>> 뒤의 .h 를 없애고, 앞에 c를 붙인다.





출처 : http://kks227.blog.me/60204924344


'Language > C++' 카테고리의 다른 글

<3> namespace (네임스페이스)  (0) 2018.02.22
<2> 레퍼런스 (reference)  (0) 2018.02.12