- Procedural language : algorithm oriented
- Structured programming language : no unconditional jump, still data is separated from algorithm
- Object oriented programming language : algorithm(behavior) + data(state) -> object
using namespace std; 를 이용하여 cout을 이용한다면
cout이라는 객체한테 그 뒤에 나오는 string 글 변수 등을 맡기는 것 - 그리고 알아서 출력을 해준다
Linux에서 c++ compile을 돌릴려면
g++ [c++ source code file name] -o [exe_file name]
./[exe_file name]
c++ 에서 initialization 하는 방법
c : int i = 0;
c++ : int i(0);
()를 이용해서도 initialization이 가능하다.
또한 C++에서는 Bool 타입이 따로 있어서 char 타입을 사용하지 않아도 된다.
namespace는 소속을 나타내 주는 것으로 std (standard) 말고도 생성이 가능하다.
[namespace]::[변수 or 함수]를 나타내 줄 수 있다.
난수를 생성할때는
#include <cstdlib>
#include <ctime>
을 넣어주고 시간의 변화에 따라 값이 랜덤하게 생성된다
srand(static_cast<unsigned int>(time(0)));
rand() % (범위에 따라 나눗셈) + (시작점 덧셈)
Reference variable
일반적인 변수
포인터 변수
그리고 c++에만 마지막으로 reference variable이라는 것이 있다.
pointer 변수와 다르게 null 값이 추가가 안되고 매개변수를 사용할 때 많이 사용한다
initialization 후에는 변경할 수 없다
File I/O
#include <fstream> 파일을 넣ㅎ고
ifstream in_file ("filename");을 통해서 파일을 넣고
ofstream out_file ("filename")을 통해서 파일을 뺸다
in_file.open()
in_file.is_open()
in_file.close()
이렇게 가능
'Programming > C++' 카테고리의 다른 글
C++ 이중포인터와 동적 다차원 배열 (0) | 2021.03.15 |
---|---|
C++ 메모리 동적 할당, 동적 할당 배열 (0) | 2021.03.15 |
c++ Pointer의 기초 (0) | 2021.03.14 |
C++ 난수 random number 만들기 (0) | 2021.03.14 |
C++ 배열의 반복 (0) | 2021.03.14 |