error LNK2019: unresolved external symbol "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl getInput(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?getInput@@YA?AV?$basic_string@DU?$char_traits@D@ std@@V?$allocator@D@2@@std@@V12@@Z) referenced in function "void __cdecl getName(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?getName@@YAXV?$basic_string@DU?$char_traits@D@st d@@V?$allocator@D@2@@std@@@Z)Code:#include <iostream> #include <string> using namespace std; string getInput(string); void start(string); void getName(string); void getAge(int); void getMileage(double); //declare variables //input as string string userInput = ""; //name as string string name = ""; //age as integer int age = 0; //mileage as double double mileage = 0.0; int main () { //call DisplayApplicationInformation cout << "This program accepts user input as a string, then makes the appropriate data conversion." << endl; start(startProgram); getName(name); getAge(age); getMileage(mileage); return 0; }//call DisplayDivider(“Start Program”) void start(string startProgram) { cout << "*********Start Program*********" << endl; }//call DisplayDivider(“Get Name”) void getName(string name) { //set name = GetInput(“Your Name”) userInput = getInput("Your Name: "); //display “Your name is: “ + name getline(cin, userInput); cout << "Your name is: " << name << endl; } //call DisplayDivider(“Get Age”) void getAge(int age) { //set input = GetInput(“Your Age”) userInput = getInput("Your Age: "); //set age = convert input to integer age = atoi(userInput.c_str()); //display “Your age is: “ + age cout << "Your Age is: " << age << endl; } //call DisplayDivider(“Get Mileage”) void getMileage(double mileage) { //set input = GetInput(“Gas Mileage”) userInput = getInput("Gas Mileage: "); //set mileage = convert input to double mileage = atof(userInput.c_str()); //display “Your car MPG is: “ + mileage cout << "Your car MPG is: " << mileage << endl; }
I take out the void start(string) altogether or change it to
void start() and I still get errors.
Not sure what I'm missing.



1Likes
LinkBack URL
About LinkBacks


