Resolve Driver Collision

#include <iostream>
using namespace std;

// Motor driver A
namespace DriverA {
    void init() {
        cout << "A INIT";
    }
}

// Motor driver B
namespace DriverB {
    void init() {
        cout << "B INIT";
    }
}

int main() {
    int x;
    cin >> x;

    if (x == 1) {
        DriverA::init();   // call driver A
    }
    else if (x == 2) {
        DriverB::init();   // call driver B
    }

    return 0;
}

Solving Approach

 

 

 

 

Upvote
Downvote
Loading...

Input

1

Expected Output

A INIT