Project design
- C++ course
- Expert
- Lesson 43/47
- 6 min
Design the skeleton of the expert final mini app.
Project: Expert final
In this 5-lesson expert final project we combine every expert topic inside one Engine class. Each lesson adds a piece: first a compile-time factorial via template metaprogramming, then a parallel sum with std::thread and std::atomic, then a volatile memory-mapped I/O simulation, and finally a C-compatible interface with extern "C".
Each lesson's starting code contains the previous lesson's solution. The project grows step by step and ends with a working mini application. The output grows by one line per lesson.
Engine class skeleton
First we define an empty Engine class. We put a static const int Version = 1; constant inside; this carries the project version at compile time. In later lessons we will add new methods on top of this skeleton.
Example: class Engine { public: static const int Version = 1; };. In main we write std::cout << "Ready"; to confirm the skeleton runs. The output is a single line: Ready. Each later lesson adds a new line.
Practice Define the Engine class skeleton
Define an Engine class. Under public: add static const int Version = 1;. In main write std::cout << "Ready";.
Starter code
#include <iostream>
// Define the Engine class here
int main() {
// Print the Ready message
return 0;
}Sample solution
#include <iostream>
class Engine {
public:
static const int Version = 1;
};
int main() {
std::cout << "Ready";
return 0;
}Expected output
Ready
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 Why use a single Engine class in this project?
class Engine { public: static const int Version = 1; };- To zero out memory usage
- To speed up the compiler
- To gather multiple topics under one roof Correct answer
- To change the operating system
Explanation: One class holds template, parallel work, register access and the C interface together.
2 Complete the class name
class ____ { public: static const int Version = 1; };
class Engine { public: static const int Version = 1; };
Explanation: Class names use PascalCase: Engine.
3 Match each piece to its role
| Term | Meaning |
|---|---|
class Engine |
Class skeleton |
static const int Version |
Compile-time constant |
std::cout |
Writing output |
"Ready" |
First output |