so i need a class that asks the user for their name and then returns "Hello<name>" so far this is what i have. the issue that im having is that it is only printing "Hello" and no asking the user for their input
Well...
Ok so you want your class to ask the user for their name and print "Hello" followed by the user's name? Why is your getName function returning an int? How does that help you? Why is the name field an int, are you expecting the person to only enter a number for name?
In main you are using a variable (name) you have not declared. Declaring it in your class does not mean you have declared it in main. Think of your class as being something entirely seperate from your main code. What are you trying to do on line 27?
Ok so you don't really need to create a class just to ask for a person's name and display it; unless specifications require it to be that way (really dumb way to practice OOP). What you want is to declare a function that asks for and displays the person's name. Also, unless you are expecting the person to enter just a number for name, I would suggest storing the person's name in a string; see http://www.cplusplus.com/reference/string/string/string/ then have the function return this string
int main()
{
returnName somebody( "Bill" ); // create a somebody, but need a constructor first?
std::cout<< "Hello " << somebody.getName()<< std::endl; // now use somebody's name
return 0;
}
Despite returnName being a very unpleasant name for a class the above might be useful. Think of a better name and take smacs advice.
alright so i changed all the things to string but the issue im having is that my class isnt returning anything. also to answer smacs question the prof wants us to create this class for a future assignment which is stupid because this could have been done in a single function in main like you said.