I have this hw problem, but I can't figure out what the problem is. If I run this code I get an assertion error. Also if i run without commenting out the return outStream line, it won't compile saying I'm converting an istream to ostream. Any clues?
#include <iostream>
#include <string>
using namespace std;
class Person
{
protected:
string name;
public:
Person():name('\0'){cout << "Default Person Constructor" << endl;}
Person(string theName):name(theName){cout << "Parameterized Person Constructor" << endl;}
Person(const Person& theObject);
string getName() const{return name;}
Person& operator=(const Person& rtSide)
{
string Name;
Name = rtSide.name;
return Person(Name);
}
friend istream& operator >>(istream& inStream, Person& personObject)
{
inStream >> personObject.name;
return inStream;
}
friend istream& operator <<(ostream& outStream, const Person& personObject)
{
outStream << "Person's name: " << personObject.name << endl;
/*return outStream;*/
}
};
class Doctor
{
protected:
string specialty;
double fee;
public:
Doctor():specialty('\0'), fee(0){cout << "Default Doctor Constructor" << endl;}
Doctor(string Specialty):specialty(Specialty), fee(0){ cout << "Specialty Doctor Constructor" << endl;}
Doctor(double Fee):specialty('\0'), fee(Fee){cout << "Fee Doctor Constructor" << endl;}
Doctor(string Specialty, double Fee):specialty(Specialty), fee(Fee){cout << "Parameterized Doctor Constructor" << endl;}
string getSpecialty() const{return specialty;}
double getFee() const{return fee;}
const Doctor& operator=(const Doctor& rtSide)
{
string Specialty;
double Fee;
Specialty = rtSide.specialty;
Fee = rtSide.fee;
return Doctor(Specialty, Fee);
}
Doctor(const Doctor& theObject);
};
class Patient: public Person
{
//protected:
// Doctor phys;
public:
Patient(): Person(){};
};
int main()
{
Person x;
system("Pause");
return 0;
}