Basic Syntax
Quick Notes
Section titled “Quick Notes”Một chương trình C++ thường bắt đầu ở hàm main.
Mỗi statement kết thúc bằng dấu ;.
Block dùng {} để gom nhiều statement.
Syntax
Section titled “Syntax”#include <iostream>
int main(){ // single-line comment std::cout << "C++\n"; return 0;}Building Blocks
Section titled “Building Blocks”| Part | Meaning |
|---|---|
#include | Nạp header |
int main() | Entry point |
{} | Scope hoặc block |
; | Kết thúc statement |
//, /* */ | Comment |
Example
Section titled “Example”#include <iostream>
namespace app{ void run() { std::cout << "Run\n"; }}
int main(){ app::run();}Common Mistakes
Section titled “Common Mistakes”- Quên
;sau statement hoặc khai báo struct/class. - Nhầm
=với==. - Lạm dụng global variable khi không cần.
Search Keywords
Section titled “Search Keywords”basic syntax cú pháp cơ bản main include namespace statement block comment