Skip to content

Tanner-Davison/cpp-primer

C++ Learning Journey

A comprehensive collection of C++ examples, exercises, and projects documenting my journey through C++ Primer 5th Edition and beyond.

๐Ÿ“š Overview

This repository represents my systematic approach to learning C++ through hands-on practice. Each chapter and concept is thoroughly explored with practical examples, ensuring deep understanding of both fundamental and advanced C++ concepts.

๐ŸŽฏ Learning Path

Phase 1: C++ Primer 5th Edition (Current)

  • Status: In Progress
  • Focus: Core language features, STL, modern C++ practices
  • Approach: Chapter-by-chapter with practical examples

Future Phases (Planned)

  • Phase 2: Effective C++ Series (Scott Meyers)
  • Phase 3: Professional C++ (Advanced topics)
  • Phase 4: Design Patterns in C++

๐Ÿ“ Project Structure

cppPrimer/
โ”œโ”€โ”€ chapters/                    # C++ Primer 5th Edition examples
โ”‚   โ”œโ”€โ”€ 5/                      # Basic language features
โ”‚   โ”œโ”€โ”€ 6/                      # Functions and debugging
โ”‚   โ”œโ”€โ”€ 7/                      # Classes and objects
โ”‚   โ”œโ”€โ”€ 7.3/                    # Advanced class features
โ”‚   โ”œโ”€โ”€ 8-streams/              # I/O streams
โ”‚   โ”œโ”€โ”€ 9-containers-and-strings/ # STL containers
โ”‚   โ””โ”€โ”€ _10-generic-algorithms/ # Generic algorithms
โ”œโ”€โ”€ projects/                    # Real-world applications
โ”œโ”€โ”€ subjects/                    # Specialized topics
โ”œโ”€โ”€ tests/                       # Testing examples
โ””โ”€โ”€ cool_finds/                  # Interesting discoveries

๐Ÿš€ Key Features

Modern C++ Focus

  • C++11/14/17/20 features throughout
  • Lambda expressions and functional programming
  • Smart pointers and RAII principles
  • Range-based for loops and auto keyword
  • Spaceship operator (<=>) examples

Comprehensive Coverage

  • STL Containers: vectors, lists, maps, sets, queues, stacks
  • Generic Algorithms: sort, find, transform, accumulate
  • Function Objects: lambdas, bind, function pointers
  • I/O Operations: file streams, string streams, iterators
  • Class Design: constructors, operators, inheritance

Practical Applications

  • Library management system
  • Phone number validation
  • Balanced brackets checker
  • Real-time console applications
  • Data processing pipelines

๐Ÿ› ๏ธ Development Environment

  • Editor: Neovim with custom C++ setup
  • Compiler: Modern C++ compiler with full C++20 support
  • Build System: Make/CMake integration
  • Language Server: clangd for IntelliSense
  • Debugging: GDB/LLDB integration

๐Ÿ“– Chapter Highlights

Chapter 5: Basic Language Features

  • Exception handling with try-catch blocks
  • String processing and validation
  • Control flow and decision making

Chapter 6: Functions

  • Function overloading and default arguments
  • Debug macros and preprocessor directives
  • Recursive function implementations
  • Reference parameters and return types

Chapter 7: Classes

  • Class design principles
  • Constructors and destructors
  • Operator overloading
  • Friend functions and classes
  • Sales data management system

Chapter 8: I/O Streams

  • File input/output operations
  • String stream processing
  • Data validation and formatting
  • Error handling in streams

Chapter 9: Containers and Strings

  • STL container operations
  • String manipulation and processing
  • Iterator safety and best practices
  • Container adapters (stack, queue)

Chapter 10: Generic Algorithms

  • Lambda expressions and closures
  • Algorithm customization
  • Iterator adapters (back_inserter, etc.)
  • Function objects and bind
  • Partitioning and sorting algorithms

๐ŸŽฎ Interactive Projects

Real-time Applications

  • Console Ticker: Real-time character animation
  • Grid Visualizer: Dynamic grid manipulation
  • Library Search: Interactive book management

Data Processing

  • Phone Number Validator: Input validation and formatting
  • Balanced Brackets: Algorithm implementation
  • Word Finder: Text processing utilities

System Design

  • Transaction Processing: Sales data management
  • Person Management: Object-oriented design
  • Debug System: Comprehensive logging framework

๐Ÿ”ง Technical Skills Demonstrated

Modern C++ Features

// Lambda expressions
auto lambda = [](const std::string &val) {
    std::cout << "Value: " << val << std::endl;
};

// Range-based for loops
for (const auto &str : my_strings) {
    // Process each string
}

// Spaceship operator (C++20)
auto operator<=>(const Point &other) const {
    if (auto cmp = x <=> other.x; cmp != 0) {
        return cmp;
    }
    return y <=> other.y;
}

STL Mastery

// Generic algorithms with lambdas
std::transform(numbers.begin(), numbers.end(),
               std::back_inserter(squared_nums),
               [](int num) { return num * num; });

// Container operations
std::erase_if(my_strings, [](int num) { return num % 2; });

Class Design

class Sales_data {
public:
    // Modern constructors
    Sales_data() = default;
    Sales_data(const Sales_data &) = default;
    
    // Operator overloading
    Sales_data &operator+=(const Sales_data &rhs);
    
    // Friend functions
    friend std::ostream &operator<<(std::ostream &os, const Sales_data &item);
};

๐Ÿ“ˆ Learning Outcomes

Programming Skills

  • โœ… Modern C++ syntax and features
  • โœ… STL containers and algorithms
  • โœ… Object-oriented design principles
  • โœ… Memory management and RAII
  • โœ… Template programming basics
  • โœ… Exception handling and error management

Development Skills

  • โœ… Neovim/Vim proficiency
  • โœ… Command-line development
  • โœ… Build system understanding
  • โœ… Debugging and testing
  • โœ… Code organization and documentation

Problem-Solving Skills

  • โœ… Algorithm implementation
  • โœ… Data structure usage
  • โœ… System design thinking
  • โœ… Performance considerations
  • โœ… Code optimization

๐ŸŽฏ Career Benefits

This systematic approach to learning C++ provides:

  1. Comprehensive Knowledge: Deep understanding of C++ fundamentals and advanced features
  2. Practical Experience: Real-world project implementations
  3. Modern Practices: Current C++ best practices and idioms
  4. Tool Proficiency: Advanced development environment skills
  5. Portfolio Material: Extensive code examples for interviews

๐Ÿš€ Getting Started

Prerequisites

  • Modern C++ compiler (GCC 10+, Clang 10+, MSVC 2019+)
  • Neovim or compatible editor
  • Make or CMake build system

Building Examples

# Navigate to any example directory
cd chapters/5/

# Compile with modern C++ standard
g++ -std=c++20 -Wall -Wextra main.cpp -o main

# Run the example
./main

Development Setup

# Clone the repository
git clone <repository-url>
cd cppPrimer

# Explore chapters
ls chapters/

# Build and run examples
make -C chapters/5/

๐Ÿ“ Notes

  • Ongoing Project: This is a living document of my C++ learning journey
  • Systematic Approach: Each concept is thoroughly explored with practical examples
  • Modern Focus: Emphasis on C++11/14/17/20 features over legacy code
  • Real Applications: Examples progress from simple to complex real-world scenarios

๐Ÿค Contributing

This is a personal learning project, but suggestions and feedback are welcome! Feel free to:

  • Report issues or bugs in examples
  • Suggest improvements to code organization
  • Share additional learning resources
  • Discuss C++ best practices

๐Ÿ“š Resources

  • Primary Text: C++ Primer 5th Edition (Stanley Lippman)
  • Reference: C++ Standard Library Reference
  • Tools: Neovim, clangd, GDB
  • Community: C++ forums and Stack Overflow

"The best way to learn a programming language is to write code in it."

This repository demonstrates that principle through systematic, hands-on learning of C++ with modern practices and real-world applications.

About

Organized Cpp Files / Projects / Examples for Teaching & Building Executable C++ Content Courses

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published