I am working on the code that reads an enum. It seems to point to an address instead
Here is the code
thanks for any help
//////////////////////////////////////////////////////////////////
//contribtor.h
#ifndef CONTRIBUTOR_H
#define CONTRIBUTOR_H
#include <iostream>
#include <string>
using namespace std;
//================================================================
//CONSTANT DEFINITIONS
enum Gender {Male=0, Female, None};
class Contributor
{
friend ostream &operator <<(ostream & Out,Contributor &InContrib);
friend istream &operator >>(istream & In, Contributor &InContrib);
public:
Contributor();
Contributor(string InContrib, double Contribution, Gender Sex, int IDKey);
Contributor(Contributor &CCContrib);
~Contributor(){cout<<"Test #1b - This is the Contributor destructor. "<<endl;}
/////Overloaded Operators
Contributor &operator=(const Contributor & RtSide);
bool operator <(const Contributor & RtSide);
bool operator >(const Contributor & RtSide);
bool operator ==(const Contributor & RtSide);
bool operator !=(const Contributor & RtSide);
private:
string InContrib;
double Contribution;
Gender Sex;
int IDKey;
};
#endif
////////////////////////////////////////////////////////////////
//contributor. cpp
#include <iostream>
#include <string>
#include <iomanip>
#include "Contributor.h"
using namespace std;
///c-tor implementation
Contributor::Contributor()
{ Contribution = 0.0f;
Sex = None;
IDKey = 0;
cout<<endl<<"Test #1a - This is the default constructor"<<endl;
}
//copy C-tor
Contributor::Contributor(string InContrib, double Contribution, Gender Sex, int IDKey)
{
InContrib=InContrib;
Contribution=Contribution;
Sex=Sex;
IDKey=IDKey;
/*cout<<"The Contributor is "<<InContrib<<endl;
cout<<InContrib <<"'s Contribution is "<<Contribution<<endl;
cout<<InContrib <<"'s Gender is "<<Sex<<endl;
*/}
Contributor::Contributor(Contributor &CCContrib)
{
//cout<<endl<<"Test #3 - This is the Copy c-tor"<<endl;
InContrib = CCContrib.InContrib;
Contribution= CCContrib.Contribution;
Sex = CCContrib.Sex;
IDKey = CCContrib.IDKey;
cout<<CCContrib<<endl;
}
ostream &operator <<(ostream & Out,Contributor &InContrib)
{
//Out<<endl<<"Name of the Contributor? " <<endl;
Out<<"Name: " <<InContrib.InContrib <<endl;
Out<<"Contribution: "<<InContrib.Contribution<<endl;
Out<<"ID Number: " <<InContrib.IDKey<<endl;
Out<<"Gender: ";
switch (InContrib.Sex)
{
case Male: cout<< "Male"; break;
case Female: cout<< "Female"; break;
//case default: cout<< "None"; break;
/*case 1: Out<<" Male ";break;
case 2: Out<<" Female "; break;*/
default: Out<<"None ";break;
}
Out<<endl<<endl<<endl;
return Out;
}
istream &operator >> (istream &In,Contributor &InContrib)
{
Gender Sex;
int IDKey;
double Contribution;
int SelSex = 0;//selection of gender
In.clear();
In.ignore(In.rdbuf()->in_avail(), '\n');
cout<<"\tEnter Contirbutors Name: ";
getline(In,InContrib.InContrib);
cout<<InContrib<<endl;
cout<<"\tEnter the amount of "<<InContrib.InContrib<<"'s contribution ";
In>>InContrib.Contribution;
cout<<Contribution<<endl;
cout<<"\tNow Enter an ID# for "<<InContrib.InContrib<<" ";
In>>InContrib.IDKey;
cout<<IDKey<<endl;
cout<<"\twhat is "<<InContrib.InContrib<<"'s Gender? "<<endl;
cout<<"\t1. Male. \n\t2. Female \n\t3. None\n\n";
In >> SelSex;
switch(SelSex)
{
case 1: InContrib.Sex = Male; break;
case 2: InContrib.Sex = Female; break;
case 3: InContrib.Sex = None; break;
}
return In;
cout<<Sex<<endl;
}
Contributor &Contributor::operator = (const Contributor & RtSide)
{
if(this != &RtSide)
{
InContrib = RtSide.InContrib;
Contribution = RtSide.Contribution;
Sex = RtSide.Sex;
IDKey = RtSide.IDKey;
}
return *this;
}
bool Contributor::operator <(const Contributor & RtSide)
{
return (InContrib <RtSide.InContrib);
}
bool Contributor::operator >(const Contributor & RtSide)
{
return (InContrib <RtSide.InContrib);
}
bool Contributor::operator ==(const Contributor & RtSide)
{
return ((InContrib == RtSide.InContrib)&&(Contribution==RtSide.Contribution)&&(Sex== RtSide.Sex));
}
bool Contributor::operator !=(const Contributor & RtSide)
{
return((InContrib != RtSide.InContrib)||(Contribution!=RtSide.Contribution)||(Sex != RtSide.Sex));
}
////////////////////////////////////////////////////////////////////////////////
//main driver
#include <iostream>
#include <string>
#include "Contributor.h"
using namespace std;
//============================================================================
// FUNCTION PROTOTYPES
//*****************************************************************************
// BEGINNING OF MAIN PROGRAM CODE
//****************************************************************************
int main()
{
//Test 1 and 5
Contributor myObj1;
//Test 2
Contributor myObj2("phillip",159.75,None,23);
//Test 3
Contributor myObj3(myObj2);// this uses the copy c-tor to make myObj3 same as myObj2
cout<<endl<<"MyObj4....";
Contributor myObj4("Hank ",4159.56,None,43);
cout<<endl<<"MyObj5.... ";
Contributor myObj5("Peggy",1549.34,Female,24);
cout<<endl<<"MyObj6....";
Contributor myObj6("Company one",1459.12,None,22);
//Test 4
cout<< "Test #4 - The Assignment of myObj1=myObj3" <<endl;
myObj1= myObj3; //now all myObjs are myObj2
cout<<myObj1;
//Test 6
cout<<"Test #6 - The >> operator " <<endl<<endl;
cin >> myObj1;
cout<<myObj1;
//Test 7
cout<<"Test #7 - The < operator " <<endl<<endl;
cout<<"\tmyOjb5 < myObj6 = "<<boolalpha<<(myObj5<myObj6)<<endl<<endl;
//Test 8
cout<<"Test #8 - The > operator "<<endl<<endl;
cout<<"\tmyObj4 > myObj6 = "<<boolalpha<<(myObj4>myObj6)<<endl<<endl;
//Test 9
cout<<"Test #9 - The == Operator\n\n";
cout<<"\tmyObj1==myObj3 = "<<boolalpha<<(myObj1 == myObj3)<<endl<<endl;
cout<<"\tmyObj1==myObj6 = "<<boolalpha<<(myObj3 == myObj6)<<endl<<endl;
//Test 10
cout<<"Test #10 - The != Operator\n\n";
cout<<"\tmyObj5==myObj3 = "<<boolalpha<<(myObj5 != myObj3)<<endl<<endl;
cout<<"\tmyObj1==myObj3 = "<<boolalpha<<(myObj1 != myObj3)<<endl<<endl;
cout <<myObj1;
return 0;
}