I got a small program here, I am just trying to return a string value from a function through a reference parameter but I keep getting an error. Any help or tips will be appreciated

using namespace std; 

int timesTen(int, string&);

int main()
    int number = 6, product;

    string outcome = "positive";

    product= timesTen(number,outcome);

    cout << product << endl;

    return 0;

int timesTen(int value, string &result)
    int product;

if ( value < 0)
    result = "negative";

cout << result << endl;

product = (value*10);

return product;


It really helps if you tell us the error message you get, and what line it points to.

In your case, it looks to be a very simple fix - you need to include the string library if you want to use the string type.

#include <string>
And strictly speaking, you are not "returning" a string from your function. It returns an int, you're modifying the string parameter.

This question has already been answered. Start a new discussion instead.