Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C - C++ Learning > cin question......
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 7 Topic 4285 of 4370
Post > Topic >>

cin question... possible to set a member variable directly from

by Ravi <Raul.Fremont@[EMAIL PROTECTED] > Sep 24, 2008 at 04:58 PM

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 >>) ?
 




 7 Posts in Topic:
cin question... possible to set a member variable directly from
Ravi <Raul.Fremont@[EM  2008-09-24 16:58:55 
Re: cin question... possible to set a member variable directly
asm23 <asmwarrior@[EMA  2008-09-25 11:23:44 
Re: cin question... possible to set a member variable directly f
Ravi <Raul.Fremont@[EM  2008-09-24 20:37:44 
Re: cin question... possible to set a member variable directly f
ConnorMcLaud@[EMAIL PROTE  2008-09-25 00:13:59 
Re: cin question... possible to set a member variable directly
Francis Glassborow <fr  2008-09-25 11:12:11 
Re: cin question... possible to set a member variable directly f
Ravi <Raul.Fremont@[EM  2008-09-26 11:27:02 
Re: cin question... possible to set a member variable directly f
"R. Scott Mellow&quo  2008-09-26 16:11:54 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Nov 21 16:56:16 CST 2008.