Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons

© 2026 BraveProgrammer. All rights reserved.

  1. Courses
  2. /
  3. C++ Course

Lesson 40 of 45 · C++

Lesson 45: Modules and Final Project Overview

Duration: 15 min

Modules and Final Project Overview\n\nC++20 modules replace the traditional preprocessor include model with a compiled module interface, dramatically reducing build times and eliminating many macro‑related pitfalls.\n\n---\n\n## Module basics\n- Interface unit (export module name;) declares what is exported.\n- Implementation unit (module name;) provides definitions.\n- Import with import name; instead of #include.\n\n## Example: Simple math module\ncpp\n// math.ixx – interface unit\nexport module math;\nexport int add(int a, int b) {\n return a + b;\n}\nexport int mul(int a, int b);\n\ncpp\n// math.cpp – implementation unit\nmodule math;\nint mul(int a, int b) {\n return a * b;\n}\n\ncpp\n// main.cpp – consumer\nimport <iostream>;\nimport math;\nint main() {\n std::cout << \"3+4 = \" << add(3,4) << '\\n';\n std::cout << \"3*4 = \" << mul(3,4) << '\\n';\n return 0;\n}\n\n\n## Final Project: Console Adventure Game\nYour capstone combines many concepts learned:\n- Classes (Player, Enemy, Map), inheritance, virtual functions.\n- Smart pointers for resource management.\n- STL containers (vector, map) for game state.\n- Filesystem for saving/loading progress.\n- Optional use of modules to split the codebase.\n\nProject roadmap:\n1. Design the data model (entities, items, map).\n2. Implement core gameplay loop with input handling.\n3. Add persistence using file I/O.\n4. (Optional) Refactor into modules.\n5. Write unit tests using the provided practical tests.\n\n> Tip: Start small – get a prototype working before adding advanced features like concurrency or networking.\n\n---\n\n<Alert type="info">Completing the project earns you the highest XP reward and a badge for "C++ Master".

Previous: Lesson 44: Ranges Library (C++20)Next: Lesson 5: Operators