Hey guys, thank you up front for taking the time to look at this thread.
My question is this,
I have written and compiled three header files that all have attributes like this:
String number; // Patient's medical record number
String firstName; // Patient's first name
char middleInitial; // Patient's middle initial
String lastName; // Patient's last name
also I have created this function in my header file as well
String customheader::getName( )
{
return firstName + " " + middleInitial + " " + lastName;
}
and also a constructor that uses all of those attributes.
When i have the constructor in my cpp filled out with all of the information it clean compiles and executes. However I want to change the program to use cin to input this information...
to clarify: I want to use String firstName(which is initialized in my header file) as a cin inside my program.
int main()
{
cout << "Please enter your first name." << endl;
cin >> firstName;
cout << "Please enter your middle initial." << endl;
cin >> middleInitial;
cout << "Please enter your last name." << endl;
cin << lastName;
customheader::getName( );
return 0;
}
and have getName use the new information and not the predefined constructor inside of the program. I have looked far and wide and cannot seem to locate the answer.. Any help would be greatly appreciated.
Well I need for the user to be able to input their own information, instead of me or another programmer having to edit the program to put in a different constructor for every user entered. Everything up until the Ex: part is in my header file, the rest is in a seperate cpp.
What I mean is, why would you need to do anything different? You have a constructor that takes the strings, and you input the strings, can't you just use the constructor and give it the strings you just inputted to?
well that is the thing, I do not have input. My previous program just had the constructor with preset values. In the new program i need to be able to put new values in and still be able to use the functions implemented in my header files. I am not sure how to do this.
when i copied that code in line for line I received over 100 errors, is their not an easier way to just cin information and have it stick to my constructor in the program or the class in my header?
String number; // Patient's medical record number
String firstName; // Patient's first name
char middleInitial; // Patient's middle initial
String lastName; // Patient's last name
¿Are those globals, or inside a class?
customheader::getName( ); ¿customheader is a namespace? ¿or getName is an static method?
Neither make sense.