This project demonstrates 3 common misconceptions in C++ that can lead to performance issues, debugging nightmares, and even crashes.
Each misconception is explained with clear examples and code that highlights the issue.
This project is part of a YouTube tutorial covering best practices and common C++ mistakes.
File | Description |
---|---|
item1_using_std_namespace_is_fine.cpp |
Demonstrates why using namespace std; can cause naming conflicts. |
item2_post_increment_is_always_fine.cpp |
Shows why i++ vs ++i matters, especially for iterators and objects. |
item3_uninitialized_pointers_are_not_null.cpp |
Explains why uninitialized pointers hold garbage values, not nullptr . |
test.bat |
Windows batch script to compile and run the selected C++ file. |
test.sh |
Linux/macOS shell script to compile and run the selected C++ file. |
Each example includes comments explaining the misconception and the correct approach.
To compile and run these examples, ensure you have:
- g++ (GNU Compiler Collection) with C++17 support
- A Windows or Linux/macOS system
- A terminal or command prompt to compile and execute the code
Check if g++
is installed by running:
g++ --version
If not installed, you can install it using:
🔹 Windows (via MinGW)
- Download MinGW from MinGW-w64.
- Install it and add g++ to the system path.
- Verify installation by running g++ --version.
🔹 Linux/macOS
sudo apt install g++ # Debian/Ubuntu
sudo yum install gcc-c++ # Fedora/CentOS
brew install gcc # macOS (using Homebrew)
./test.bat
./test.sh
This project is part of a YouTube tutorial that explains the code in detail. Watch the video to follow along.
This project is licensed under the MIT License.
Happy coding! 🚀