in one of my assignments i was asked to create a lamp in c++ that contains bulbs and able to switch the bulbs at will. CLamp has an instant of CBulb inside of it. This is part of the solution for the lab:
in the CLamp class:
CLamp::CLamp(const CLamp& oldLamp)
{
bptr = new CBulb;
*bptr = *(oldLamp.bptr);
}
and:
CBulb *CLamp::ExchangeBulb(CBulb *theNewBulb)
{
CBulb *tmp = bptr;
bptr = theNewBulb;
return tmp;
}
in the main:
CLamp lamp1(*some number*);
CBulb *testbptr = new CBulb(*some other number*);
CBulb *temp = lamp1.ExchangeBulb(testbptr);
delete temp;
so what does CBulb *CLamp::ExchangeBulb(CBulb *theNewBulb)
mean? What is ExchangeBulb
a member function of? also does this mean that *Clamp
is an object of type CBulb
? thanks in advance for you time.