Taxonomy of the C language
Structure of a C++ program
Preprocessor Directives |
# include <iostream> - 의미 : 나는 이미 정의된 iostream 이라는 library를 사용하고 싶다 - 언제나 #로 시작 - iostream : a library for inputs and outputs |
Global Declarations |
using namespace std; - namespace std는 기본 C++ library의 모든 class, object, function을 포함함 |
int main() { Local Definitions statements } |
int main() - 프로그램의 중심 - compiler는 프로그램을 어디서부터 시작해야 할지 찾을 때 main()을 위치함 - 함수 { cout << “Hello world!\n”; (이구문에서 namespace 없이 쓸려면 std::cout<<“Hello world!\n”; 이라고 써야함) return 0; } 여기서 cout에 대해서는 또 여러가지가 있는데... 나중에... |
int ex(...) { Local Definitions Statements }//ex |
나중에... |
Comment
- 프로그램 내부에 코멘트를 달 때, 프로그램 code라고 생각하지 않음.
// : single line comment
/* : start of commetn
*/ : end of comment
Identifiers
- 인간이 외우기 어려우므로 식별자를 부여
- A-Z, a-z, 0-9, _ 가능
- 숫자로 시작 불가능
- if, case, while 같은 이미 의미부여된 단어 사용 불가능
- 의미축약적인 단어가 좋은 이름
- 대소문자 구별 -> PI, Pi, pi는 다른 의미!
Standard Data Types
- Void
- Int
- short int : 2 Bytes
- int : 2 or 4 Bytes
- long int : 4 Bytes
- char
- float
- float : 4 Bytes
- double : 8 Bytes
- long double : 10 Bytes
- bool
* C++의 Boolean(컴퓨터와 전자공학에서 참과 거짓을 나타내는 숫자 1과 0만을 이용하는 방식) 상수는 true, false.
* 전통적인 기준에 따르면, nonzero number 는 true, zero 는 false
Variables
- Variables = Identifier + Type
Variables Declaration = Type assignment & Identifier
Variable Declaration이 Variable initialization은 아님
ex)
int count; declaration (o), initialization(x)
char grade = ‘d’; declaration (o), initialization(o)
Constants
프로그램 실행동안 Data value로 바꿀 수없는 것
ex)
Integer constant 4
Float constant 3.141592
Character constant ‘d’
Character constant ‘\0’
String constant “Hello word”
-> bool type constant 만 true 가 1로, false가 0으로 된다.
순서도(Flowchart)
- 문제를 이해한 뒤, 논리의 설계 과정에서 필요. 이후 프로그램 코딩
- 즉, 문제를 해결하는데, 논리적인 단계들을 그림으로 표현하는 것.
- 그러니까 논리적인 흐름을 나타내는데 용이하겠지?
순서도 기호(Symbols)
기본구조
- 순서(sequence)
- 선택(selection)
- 루프(loop)
이 세가지면 모든 논리를 표현할 수 있다.
'DEVELOPMENT > C++' 카테고리의 다른 글
C++ : 언어의 발전개요 및 프로그래밍의 개발과정 (0) | 2017.01.21 |
---|