Skip to content

petsereypanha/cpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

30 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

C++ Programming Lessons - Complete Learning Path

Language Platform License

A comprehensive, hands-on C++ learning repository organized as a structured course. Each lesson is self-contained with practical examples you can compile and run independently. Progresses from beginner fundamentals to intermediate concepts using modern C++20+ standards.

🎯 Project Overview

This repository contains 9 comprehensive modules covering essential C++ programming concepts:

  • 90+ practical examples across different difficulty levels
  • Self-contained lessons - each .cpp file compiles independently
  • Modern C++ practices (C++20+ standards)
  • Real-world applications and exercises
  • Progressive difficulty from basics to advanced topics

πŸš€ Quick Start

Prerequisites

# macOS (recommended)
xcode-select --install                    # Apple Clang compiler
brew install cmake llvm clang-format     # Optional tools

# Verify installation
clang++ --version

Compile & Run Any Lesson

# Create build directory
mkdir -p build

# Compile with modern C++ standards and warnings
clang++ -std=c++20 -Wall -Wextra -Wpedantic -g introduction/Test.cpp -o build/test
./build/test

# With sanitizers (debug mode)
clang++ -std=c++20 -g -O0 -fsanitize=address,undefined pointer/startPointer.cpp -o build/pointer_demo
./build/pointer_demo

πŸ“š Learning Path & Course Structure

🌟 Module 1: Introduction & Fundamentals

Folder: introduction/

  • Test.cpp - Hello World and basic I/O
  • Test2.cpp - Variables and data types
  • operator.cpp - Arithmetic, logical, and comparison operators

Key Concepts: Basic syntax, cout/cin, variables, operators, type system

πŸ”€ Module 2: Conditional Logic

Folder: condition/

  • if.cpp - Basic if statements
  • if_else.cpp - If-else branching
  • if_else_if.cpp - Multi-branch conditions
  • switch.cpp - Switch-case statements
  • TernaryOperator.cpp - Conditional operator (?:)
  • nested_statement.cpp - Nested conditional logic

Key Concepts: Decision making, branching logic, control flow

πŸ”„ Module 3: Loops & Iteration

Folder: loop/

  • for_loop.cpp - For loop fundamentals
  • while_loop.cpp - While loop patterns
  • do_while_loop.cpp - Do-while loops
  • nested_loop.cpp & nested_loop_2.cpp - Nested iteration
  • goto_label.cpp - Label and goto (educational)
  • pow.cpp & pow_2.cpp - Mathematical calculations
  • sum_data.cpp - Data processing examples
  • worker.cpp - Real-world loop applications

Key Concepts: Iteration, nested loops, loop control, algorithms

πŸ› οΈ Module 4: Functions & Modularity

Folder: function/

  • return_none_param.cpp - Functions without parameters
  • return_has_param.cpp - Functions with parameters
  • none_return_param.cpp & none_return_has_param.cpp - Void functions
  • function_PassByValue.cpp & function_PassByValue1.cpp - Pass by value
  • function_PassByReferent.cpp - Pass by reference
  • overloading.cpp & overloading2.cpp - Function overloading
  • recursive_function.cpp & recursive_function2.cpp - Recursion
  • persion.cpp & product.cpp - Real-world examples

Key Concepts: Function design, parameter passing, recursion, overloading

πŸ“Š Module 5: Arrays & Data Collections

Folder: array/

  • hello.cpp - Basic array operations
  • test.cpp - Array fundamentals
  • TwoArra.cpp & arrayTwoDimension.cpp - 2D arrays
  • userTwoDimension.cpp - Interactive 2D array input
  • ThreeDimansion.cpp - 3D array operations
  • persion.cpp & employee.cpp - Object arrays
  • product.cpp & catogory.cpp - Real-world data structures

Key Concepts: Array manipulation, multi-dimensional arrays, data organization

🎯 Module 6: Pointers & Memory Management

Folder: pointer/

  • startPointer.cpp - Pointer fundamentals
  • levelPointer.cpp - Multi-level pointers
  • pointerArray.cpp - Pointer-array relationship
  • mallocPointer.cpp & mallocPointerTwo.cpp - Dynamic allocation
  • callocOne.cpp - Calloc memory allocation
  • realloc.cpp - Memory reallocation
  • functionPointer.cpp & functionPointerRedom.cpp - Function pointers

Key Concepts: Memory management, dynamic allocation, pointer arithmetic

πŸ—οΈ Module 7: Structures & Custom Types

Folder: structure/

  • helloStructure.cpp - Basic struct definition
  • nestedStruct.cpp - Nested structures
  • bookArray.cpp & employeeArray.cpp - Arrays of structures
  • objectPointer.cpp - Pointer to structures
  • objectStructArray.cpp - Complex data organization
  • typedefStructure.cpp - Type aliases
  • errorStudent.cpp - Error handling examples

Key Concepts: Data encapsulation, custom types, structured programming

πŸ”§ Module 8: Templates & Generic Programming

Folder: template/

  • function_template.cpp - Function templates
  • struct_template.cpp - Class templates
  • two_template.cpp - Multiple template parameters

Key Concepts: Generic programming, code reusability, template specialization

⚠️ Module 9: Exception Handling

Folder: exception/

  • exception.cpp - Try-catch blocks, throwing exceptions

Key Concepts: Error handling, exception safety, robust programming

πŸ› οΈ Development Setup

Recommended Compiler Flags

# Development (with warnings)
-std=c++20 -Wall -Wextra -Wpedantic -Wconversion -Wshadow -g

# Debug (with sanitizers)
-std=c++20 -g -O0 -fsanitize=address,undefined -fno-omit-frame-pointer

# Release (optimized)
-std=c++20 -O2 -DNDEBUG

Optional: CMake Project Setup

Create a unified build system:

# CMakeLists.txt
cmake_minimum_required(VERSION 3.20)
project(cpp_lessons LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Add compiler warnings
add_compile_options(-Wall -Wextra -Wpedantic)

# Example executable
add_executable(lesson_runner src/main.cpp)

πŸ“– Learning Recommendations

Beginner Path (Modules 1-3)

  1. Start with introduction/ - understand basic syntax
  2. Master condition/ - learn decision making
  3. Practice loop/ - understand iteration patterns

Intermediate Path (Modules 4-6)

  1. Study function/ - learn modular programming
  2. Explore array/ - understand data collections
  3. Master pointer/ - learn memory management

Advanced Path (Modules 7-9)

  1. Build with structure/ - create custom types
  2. Generalize with template/ - write reusable code
  3. Handle errors with exception/ - robust programming

πŸŽ“ Project Ideas & Exercises

Beginner Projects

  • Calculator (modules 1-3): Basic arithmetic with menu system
  • Grade Manager (modules 4-5): Student grade calculations and arrays
  • Simple Games (loops + conditions): Number guessing, tic-tac-toe

Intermediate Projects

  • Contact Manager (structures + arrays): Store and search contacts
  • File Processor (pointers + functions): Read/write text files
  • Data Analyzer (templates): Generic statistical functions

Advanced Challenges

  • Memory Pool (pointers + templates): Custom memory allocator
  • Expression Parser (all concepts): Mathematical expression evaluator
  • Mini Database (structures + templates + exceptions): Data storage system

πŸ”§ Troubleshooting

Common Issues

# Compiler not found
xcode-select --install

# Permission denied
chmod +x ./build/program_name

# Memory errors
# Recompile with: -fsanitize=address,undefined -g

Code Style

  • Use clang-format for consistent formatting
  • Enable clang-tidy for static analysis
  • Follow modern C++ best practices (RAII, smart pointers)

πŸ“ˆ Progress Tracking

  • Module 1: Introduction & Fundamentals
  • Module 2: Conditional Logic
  • Module 3: Loops & Iteration
  • Module 4: Functions & Modularity
  • Module 5: Arrays & Data Collections
  • Module 6: Pointers & Memory Management
  • Module 7: Structures & Custom Types
  • Module 8: Templates & Generic Programming
  • Module 9: Exception Handling

🀝 Contributing

Feel free to:

  • Add new examples to existing modules
  • Create additional modules (STL, OOP, Concurrency)
  • Improve existing code with modern C++ features
  • Add unit tests for examples

πŸ“š Additional Resources

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


Happy Learning! πŸš€ Start with introduction/Test.cpp and work your way through each module systematically.

Releases

No releases published

Packages

No packages published

Languages