Created
January 24, 2018 15:03
-
-
Save pkulev/fad7c4972b5dd3aea38bb96404a56a17 to your computer and use it in GitHub Desktop.
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