Code:
class Mammal
{
public:
// constructors
Mammal(){}
~Mammal(){}
//accessors
int GetAge()const { return itsAge; }
void SetAge(int age) { itsAge = age; }
protected:
int itsAge;
};
int main()
{
int x;
Mammal fido;
std::cin >> x ;
fido.SetAge(x);
return 0;
}
The code above reads in the variable x from input device and then
calls fido.SetAge(x) to set the age.
It works, but I am wondering is there any way to directly set the age
from the input device?
Something like,
fido.SetAge(std::cin >>) ?