This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <map> | |
#include <iostream> | |
using namespace std; | |
class NetworkInterface { | |
public: | |
int a = 5; | |
NetworkInterface(int a): a(a) {} | |
}; | |
class SubnetInterface : public NetworkInterface { | |
public: | |
SubnetInterface(int a): NetworkInterface(a * 10) {} | |
}; | |
class SwitchInterface : public NetworkInterface { | |
public: | |
SwitchInterface(int a): NetworkInterface(a * 100) {} | |
}; | |
int main() { | |
std::map<std::string, NetworkInterface> interfaces = { | |
{"subnet", SubnetInterface(1)}, | |
{"switch", SwitchInterface(1)}, | |
}; | |
NetworkInterface ni = NetworkInterface(10); | |
cout << "ablabla: " << ni.a << endl; | |
SubnetInterface si = SubnetInterface(10); | |
cout << "blablab: " << si.a << endl; | |
SwitchInterface swi = SwitchInterface(10); | |
cout << "aaaaaaa: " << swi.a << endl; | |
cout << interfaces["subnet"].a; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment