Sunday, February 25, 2018

C++ Program : Multiple Inheritance

#include<iostream>
using namespace std;
class USBDevice { long m_lID;
public:
USBDevice(long lID) : m_lID(lID) {}
long GetID() { return m_lID; }
};
class NetworkDevice { long m_lID;
public:
NetworkDevice(long lID) : m_lID(lID) {}
long GetID() { return m_lID; }
};
class WirelessAdaptor : public USBDevice, public NetworkDevice {
public:
WirelessAdaptor(long lUSBID, long lNetworkID)
: USBDevice(lUSBID), NetworkDevice(lNetworkID) {}
};
int main() {
int lUSBID, lNetworkID;
cin >> lUSBID >> lNetworkID;
WirelessAdaptor c54G(lUSBID, lNetworkID);
cout<<c54G.USBDevice::GetID();
cout<<":";
cout<<c54G.NetworkDevice::GetID();


return 0;
}

Thanks
Happy  Programming !

No comments:

Post a Comment

How can I run a C++ program directly from Windows?

How-can-I-run-a-C-program-directly-from-Windows