#include <iostream>
using namespace std;
namespace Config {
int baudRate = 9600;
int threshold = 50;
}
int main() {
cout << "Baud: " << Config::baudRate
<< ", Threshold: " << Config::threshold;
return 0;
}
Explanation & Logic Summary:
- The namespace
Config is predefined. - The user simply declares two variables inside it.
- In
main(), the variables are accessed as Config::baudRate and Config::threshold.
Layman’s Terms
Think of Config like a settings folder. You put baudRate and threshold inside, and the program fetches them from there.
Firmware Relevance & Real-World Context:
This mirrors how embedded firmware often groups constants and configuration values in namespaces for organization and type safety.