A comprehensive collection of C++ examples, exercises, and projects documenting my journey through C++ Primer 5th Edition and beyond.
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.
- Status: In Progress
- Focus: Core language features, STL, modern C++ practices
- Approach: Chapter-by-chapter with practical examples
- Phase 2: Effective C++ Series (Scott Meyers)
- Phase 3: Professional C++ (Advanced topics)
- Phase 4: Design Patterns in C++
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
- 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
- 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
- Library management system
- Phone number validation
- Balanced brackets checker
- Real-time console applications
- Data processing pipelines
- 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
- Exception handling with try-catch blocks
- String processing and validation
- Control flow and decision making
- Function overloading and default arguments
- Debug macros and preprocessor directives
- Recursive function implementations
- Reference parameters and return types
- Class design principles
- Constructors and destructors
- Operator overloading
- Friend functions and classes
- Sales data management system
- File input/output operations
- String stream processing
- Data validation and formatting
- Error handling in streams
- STL container operations
- String manipulation and processing
- Iterator safety and best practices
- Container adapters (stack, queue)
- Lambda expressions and closures
- Algorithm customization
- Iterator adapters (back_inserter, etc.)
- Function objects and bind
- Partitioning and sorting algorithms
- Console Ticker: Real-time character animation
- Grid Visualizer: Dynamic grid manipulation
- Library Search: Interactive book management
- Phone Number Validator: Input validation and formatting
- Balanced Brackets: Algorithm implementation
- Word Finder: Text processing utilities
- Transaction Processing: Sales data management
- Person Management: Object-oriented design
- Debug System: Comprehensive logging framework
// 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;
}
// 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 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);
};
- โ 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
- โ Neovim/Vim proficiency
- โ Command-line development
- โ Build system understanding
- โ Debugging and testing
- โ Code organization and documentation
- โ Algorithm implementation
- โ Data structure usage
- โ System design thinking
- โ Performance considerations
- โ Code optimization
This systematic approach to learning C++ provides:
- Comprehensive Knowledge: Deep understanding of C++ fundamentals and advanced features
- Practical Experience: Real-world project implementations
- Modern Practices: Current C++ best practices and idioms
- Tool Proficiency: Advanced development environment skills
- Portfolio Material: Extensive code examples for interviews
- Modern C++ compiler (GCC 10+, Clang 10+, MSVC 2019+)
- Neovim or compatible editor
- Make or CMake build system
# 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
# Clone the repository
git clone <repository-url>
cd cppPrimer
# Explore chapters
ls chapters/
# Build and run examples
make -C chapters/5/
- 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
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
- 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.