Jump to content

Help with C++

Sdot

I keep getting two errors that I need assistance with.

 

above main I have

string getInput(string);

below main I have

void getInput(string prompt) //Here is where I get the error that reads, "cannot overload functions distinguished by return type alone"{          string theInput;          cout << prompt << endl;          cin >> theInput;          return theInput; //Here is where I get the error that reads, "return type does not match the function type"}
Link to comment
Share on other sites

Link to post
Share on other sites

 

I keep getting two errors that I need assistance with.

 

above main I have

void getInput(string);

below main I have

void getInput(string prompt) //Here is where I get the error that reads, "cannot overload functions distinguished by return type alone"{          string theInput;          cout << prompt << endl;          cin >> theInput;          return theInput; //Here is where I get the error that reads, "return type does not match the function type"}

A void function doesn't return anything. Shouldn't return anything. Also, I think your function declaration is wrong, it should be void getInput(string);, not string getInput(string);.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×