Need to add info to section of program

closed account (zwUqko23)
How do I add information to this section of my program?
I need to add last name, month of birth, day of birth, year of birth, etc....



// get first name
string getFirst()
{
return First;
} // end function getFirst
You've only shown us a tiny bit of your program, and your question is very vague.

Do you want to create more functions, each of which returns a single property, e.g. getLast(), getMonth(), etc? Or do you want a single function that passes back all the properties at once?

Is getFirst() a free function? A method of a class?

Where is First defined?
more details are
required;

anyway this
is an example
passing a string
variabale by reference;


What is your name?
>>Churchill    
Hello: Churchill


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//InfoString.cpp
//##

#include <iostream>
using std::cout;
using std::cin;
using std::endl;

#include <string>
using std::string;
using std::getline;



void getUserInfo(string& name);

int main(){

        string text; //variable to store username
        getUserInfo(text);

        cout<<"Hello: "<<text<<endl;

return 0; //indicates success
}//end of main


void getUserInfo(string& name){
        cout<<"What is your name?\n>>";
        getline(cin,name);
}//end function getUserInfo 
closed account (zwUqko23)
My program is quite long. I am building a Health Profile.... and First is First Name, Here is the program so far above and below that section.

// set first name
void setFirst ( string first )
// set last name
void setLast( string last )
// set gender
void setGender( string gender )
// set today’s month
void settodaysmonth( string todaysmonth )
// set today’s day
void set todaysday( string todaysday )
// set today’s year
void set todaysyear( string todaysyear )
// set month of birth
void setmonthofbirth( string monthofbirth )
// set day of birth
void setdayofbirth( string dayofbirth )
// set year of birth
void setyearofbirth( string yearofbirth )
// set current age
void currentage( string currentage )
// set weight
void setWeight( string Weight )
// set height
void setHeight( string Height )
{
First = First;
Last = Last;
Gender = Gender;
todaysmonth = todaysmonth
todaysday = todaysday
todaysyear = todaysyear
monthofbirth = monthofbirth
dayofbirth = dayofbirth
yearofbirth = yearofbirth
currentage = currentage
Weight = Weight
Height = Height
} // end function sets all functions

// get first name
string getFirst()
{
return First;
} // end function getFirst


private:
string First; // person's first name
string Last; // person’s last name
string Gender; // person’s gender
string todaysmonth; // current month
string todaysday; // current day
string todaysyear; // current year
string monthofbirth // person’s month of birth
string dayofbirth // person’s day of birth
string yearofbirth // person’s year of birth
string currentage // person’s current age
string Weight // person’s weight in pounds
string Height // person’s height in inches

Why is a method called "SetHeight" trying to set the values of First, Last, Gender, etc?

In that method, what is it that you think this line is doing:

First = First;

?

(as an example - I could have picked any of the lines in that function except for the last one).

EDIT: And please use code tags when posting code, to make it readable:

http://www.cplusplus.com/articles/z13hAqkS/
Last edited on
closed account (zwUqko23)
Good question. I am new to C++ and trying to go by what someone told me. I figured this was wrong but I am working by trial and error. What do I need to do to fix this??

And I have no idea what First=First is supposed to do, I am working on that now. I think those should be if statements.

you can read tutorial from here http://www.cplusplus.com/doc/tutorial/

and that First=First, you will know what it means here http://www.cplusplus.com/doc/tutorial/variables/
I don't mean to be harsh, but if you're confused by even simple assignment statements, then you should really be spending more time reading your textbook and/or tutorial. You need to be able to grasp the basics before you write code, otherwise you're going to get nowhere.
closed account (zwUqko23)
point taken... This will be the last you'll see of me!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Well... that was unexpected. My advice was sincerely meant, and I believe it was sound. I certainly didn't mean to encourage anyone to leave the forum.

Oh well.
Last edited on
closed account (iAk3T05o)
@mikeyboy: Sincerely, you do that a lot.
Topic archived. No new replies allowed.