User imput string int and float[DOUBT]

Jean Cesar via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Feb 15 15:20:29 PST 2017


How do I make a class person where I use set and get methods to 
imput the user type:

Import std.stdio;

class person
{
   private:
   string name, address;
   int age;
   float height;

public:
   void setNome()
   {
     write("Enter Your Name:");
     // the problem is here how am I going to read the imput of a 
string typed by the user?
   }

void setIty()
{
    write("Enter Your Age:");
   // Another problem here also to read integer values like I 
would?
}

void setHeight()
{
   write("Enter Your Height:");
   // Another problem here also to read floats or double values 
like I would?
}

float getHeight()
{
   return height;
}

int getIty()
{
   return age;
}

string getNome()
{
   return name;
}

}

void main ()
{
   person p = new person();

   p.setName();
   p.setIdade();
   p.setHeight();

   p.getName();
   p.getIdade();
   p.getHeight();
}



More information about the Digitalmars-d-learn mailing list