A
Alicia
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:stream& operator<<(std:stream& 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 CostedCallublic 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:perator<<(out,phonecall);
return out;
}
I am completely lost. Any help would be appreciated.
Alicia
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:stream& operator<<(std:stream& 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 CostedCallublic 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:perator<<(out,phonecall);
return out;
}
I am completely lost. Any help would be appreciated.
Alicia