learn-cpp is a code-short note to understand the basics of C++, designed as a simple, code-first learning aid. To learn, users can uncomment the code lines and execute the file to see how each concept works in practice. It briefly covers core theory such as data types, variables, constants, namespaces, type conversions, input handling, operators, control flow, loops, functions, arrays, pointers, recursion, structs, classes, constructors, inheritance, and templates.
Designed and developed by Supun Wijesooriya.
The learn-cpp notes include the following:
-
Core Types and Variables
- Integers, doubles, chars, booleans, and strings
- Constants and basic assignments
-
Operators and Conversions
- Arithmetic and logical operators
- Implicit and explicit type conversions
-
Input and Strings
- User input with
std::cinandstd::getline - String utilities and indexing
- User input with
-
Control Flow
- If/else and switch statements
- Ternary operator usage
-
Iteration
- While, do-while, and for loops
- Nested loops and loop control
-
Functions and Reuse
- Function definitions and overloading
- Return values and recursion
-
Arrays and Memory
- Arrays and multi-dimensional arrays
- Pointers, references, and memory addresses
-
Structures and OOP
- Structs and enums
- Classes, constructors, getters/setters, and inheritance
-
Templates
- Function templates for generic behaviour
- C++23: Core language used for all examples
- No External Libraries: All code uses only standard C++ headers
learn-cpp/
├── .vscode/
│ ├── settings.json
│ └── tasks.json
├── helloworld.cpp
└── helloworld.exe
To run the notes locally, follow these steps:
-
Open the repository folder.
-
Uncomment the code lines you want to try in
helloworld.cpp. -
Compile the file in your terminal:
g++ -std=c++23 helloworld.cpp -o helloworld
-
Run the program:
./helloworld
This project is a console-based learning note and does not include graphical user interfaces.
This project was developed by:
- Supun Wijesooriya
Contributions are welcome. If you would like to contribute, please follow these steps:
-
Fork the repository.
-
Create a new branch:
git checkout -b feature/your-feature-name
-
Make your changes and commit them:
git commit -m "Add your commit message" -
Push your changes to your forked repository:
git push origin feature/your-feature-name
-
Open a pull request to the main repository.
- These notes are intended for learning and revision of C++ fundamentals.
- Uncomment only the sections you want to run to avoid conflicting inputs.
- Examples are intentionally minimal to keep the focus on core concepts.
For any enquiries or feedback, please contact the developer:
- Supun Wijesooriya: GitHub Profile
- Project Repository: learn-cpp