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

Sacred Thought

5 May 2024 Hari Om Verse 50-51, chapter two:  In this chapter two Shree krishna explains a simple way of living. Free from desires and void ...