I keep getting this error for the Pet read function: no match for 'operator>>' in 'fin >> ((Pet*)this)->Pet::age' whenever trying to compile the class. I have not implemented anything into main, but I am trying to figure out how to fix this problem so I can go on. Any help or insight is appreciated.
#include <iostream>
using namespace std;
class Pet
{
protected:
string name;
double age;
public:
Pet();
Pet(string name, double age);
void setName( string name);
void setAge (double age);
string getName ();
double getAge ();
void print(ostream &out = cout);
void read(ifstream &fin);
~Pet();
};
Pet::Pet(string namevalue, double agevalue)
{
name=namevalue;
age=agevalue;
}
Pet::Pet()
{
name="";
age=0;
}
void Pet::setName (string input)
{
name=input;
}
void Pet::setAge (double input)
{
age=input;
}
string Pet::getName()
{
return name;
}
double Pet::getAge()
{
return age;
}
void Pet::print(ostream &out = cout) //this is where the error exists
{
cout << name << " " << age << endl;
}
void Pet::read(ifstream &fin) //this is where the error exists
{
fin >> age >> name;
}