Hello,
I am trying to figure out how to call an overloaded operator<<
inherited from a base class.
#ifndef PHONECALL
#define PHONECALL
#include "time.h"
#include "interval.h"
enum CallType {LOCAL, LONG_DISTANCE};
class PhoneCall
{
public:
friend std::istream& operator>>(std::istream& in, PhoneCall&
phoneCall);
friend std::ostream& operator<<(std::ostream& out, const
PhoneCall& phoneCall);
CallType getCallType() const;
int callLength() const;
private:
CallType callType;
Interval<Time> interval;
};
#endif
Here is the inherited class:
#include "phonecall.h"
#include "money.h"
#include <iostream>
class CostedCall:public PhoneCall
{
public:
CostedCall();
CostedCall(PhoneCall phoneCall, Money cost);
friend ostream& operator<<(ostream& out, const CostedCall&
phonecall);
private:
Money cost;
};
The output on the base class PhoneCall works correctly. What I need to
know is how to call the operator<< in the base class PhoneCall from
the derived class CostedCall. I tried something like this:
ostream& operator<<(ostream& out,const CostedCall& phonecall)
{
PhoneCall::operator<<(out,phonecall);
return out;
}
I am completely lost. Any help would be appreciated.
Alicia