#include <iostream> using namespace std; namespace Communication { namespace I2C { int speed = 400000; // 400 kHz } } int main() { namespace CI = Communication::I2C; cout << "I2C Speed: " << CI::speed; return 0; }
Solution Explanation
CI = Communication::I2C;
Communication::I2C::speed
CI::speed
Layman’s Terms
It’s like making a shortcut folder on your desktop so you don’t have to keep going through a long path every time.
Significance for Embedded Developers
Embedded projects often have deeply nested namespaces for hardware abstraction layers (HALs).
Aliasing makes code shorter and easier to read without losing clarity.
Test Cases
Test Results
Input
Expected Output
I2C Speed: 400000