Introduction
Quick Notes
Section titled “Quick Notes”C++ là ngôn ngữ biên dịch, hỗ trợ procedural, object-oriented và generic programming. Nó thường dùng cho hệ thống, game engine, embedded, performance-critical backend và competitive programming. Các compiler phổ biến: GCC/G++, Clang và MSVC.
Syntax
Section titled “Syntax”#include <iostream>
int main(){ std::cout << "Hello World"; return 0;}Compile
Section titled “Compile”| Tool | Platform | Command |
|---|---|---|
| G++ | Linux, macOS, Windows | g++ main.cpp -std=c++20 -O2 -Wall -o main |
| Clang++ | Linux, macOS, Windows | clang++ main.cpp -std=c++20 -O2 -Wall -o main |
| MSVC | Windows | cl /std:c++20 /EHsc main.cpp |
Compile process: preprocess -> compile -> assemble -> link.
Example
Section titled “Example”#include <iostream>#include <string>
int main(){ std::string name; std::cin >> name; std::cout << "Hi, " << name << '\n';}Common Mistakes
Section titled “Common Mistakes”- Quên
#includecho thư viện đang dùng. - Trộn C++ standard quá cũ với cú pháp C++17/20.
- Dùng
using namespace std;trong header file.
Search Keywords
Section titled “Search Keywords”cpp introduction c++ là gì g++ gcc clang msvc compile biên dịch hello world