C++20 sections · 1024 units
Open in Course

Common Mistakes

Typical errors

Forgetting the semicolon after struct definition. struct Point { int x; int y; } without semicolon causes cryptic errors. The semicolon is required, always. Using dot operator on pointers instead of arrow.

If you have Point *p, you need p->x not p.x. you'll cover pointers to structs later, but watch for this. Not initializing before use. Point p; cout << p.x; prints garbage. Always initialize: Point p{0, 0}; or assign values before reading.