C++ Tutorial 1 서강대학교 데이터베이스 연구실
Introduction 1 C++ is almost a superset of the C programming language - generally a C code is valid in C++. but not always, since C++ is stricter than C in some respects (such as typechecking for function parameters) The following is a sample code that works both in C and C++ #include <stdio.h>-instructs the compiler to include the declaration of the standard input/output library functions (which declares "printf" among other things) This program defines a function called main. Every C or C++ program must have a function called main and the program starts by executing this function. The body of this function main contains a call to printf function which writes "Hello, World!₩n" to the standard output. Backslash (“₩") followed by another character denotes a special character: in this case ₩n is a newline character. main is of type int and returns the value 0 to the operating system.
Introduction 2 The following program (valid for C++ only) produces the same result as the previous one. This program uses "streams". special classes used for input and output. cout is the standard output stream. The opeator << ("puts to")writes its second argument into the first. In this case. the string "Hello, World!₩n“ is written onto the standard output stream cout.
Fundamental Types (Same for C and C++) Keyword Explanation char character (occupies 1 byte) int integer (occupies 1 word) long int integer (occupies 32bits) float floating point number-single precision (6 digits) double floating point number-double precision (15 digits) int 형은 32bit 를 유지합니다. short 형은 16bit 를 유지합니다. long 형은 32bit에서 64bit로 확장됩니다. long long 형은 64bit 를 유지합니다. pointer 형은 32bit 에서 64bit로 확장딥니다. long double 형이 12bytes 에서 16bytes로 확장됩니다. size_t과 ssize_t 형이 32bit 에서 64bit 로 확장됩니다. 이와 관련된 typedef 문 역시 확장됩니다.
Fundamental Types in 64bit system Keyword Explanation char 1byte -> 1byte int 32bit -> 32bit long int 32bit -> 64bit long long int 64bit -> 64bit pointer long double 12bytes -> 16bytes size_t / ssize_t int 형은 32bit 를 유지합니다. short 형은 16bit 를 유지합니다. long 형은 32bit에서 64bit로 확장됩니다. long long 형은 64bit 를 유지합니다. pointer 형은 32bit 에서 64bit로 확장딥니다. long double 형이 12bytes 에서 16bytes로 확장됩니다. size_t과 ssize_t 형이 32bit 에서 64bit 로 확장됩니다. 이와 관련된 typedef 문 역시 확장됩니다.
Example Example using basic types
Example
Derived Types (All exist in C except for reference)
Derived Types (All exist in C except for reference)
Derived Types (All exist in C except for reference)
Derived Types (All exist in C except for reference)
Derived Types (All exist in C except for reference)
Derived Types (All exist in C except for reference)
Derived Types (All exist in C except for reference)