#include <iostream>
using namespace std;
namespace Config {
namespace ADC { int resolution = 12; }
namespace PWM { int frequency = 1000; }
}
int main() {
cout << "ADC.resolution=" << Config::ADC::resolution << "\n";
cout << "PWM.frequency=" << Config::PWM::frequency << "\n";
return 0;
}
Explanation & Logic Summary:
- The nested namespaces are already provided.
- The learner just accesses them using
Config::ADC::resolution and Config::PWM::frequency.
Layman’s Terms
It’s like we already made two subfolders inside Config — one for ADC, one for PWM. You just need to open them and read what’s inside.
Firmware Relevance & Real-World Context:
This is very common in firmware projects:
Config::ADC might store ADC resolution settings.Config::PWM might store PWM frequency values.
It’s a neat way to organize subsystem-specific parameters.