What return type is needed to return a c++ style string?
Code:???? GetObject(std::string Option);
{
std::string DirOrFileName;
std::cout"Please enter "<<Option;
getline(std::cin,DirOrFileName,'\n');
return DirOrFileName;
}
What return type is needed to return a c++ style string?
Code:???? GetObject(std::string Option);
{
std::string DirOrFileName;
std::cout"Please enter "<<Option;
getline(std::cin,DirOrFileName,'\n');
return DirOrFileName;
}
Code:std::string GetObject(std::string Option) // No semi-colon
{
std::string DirOrFileName;
std::cout << "Please enter "<< Option; // Blah blah blah
std::getline(std::cin,DirOrFileName,'\n'); // Blah blah blah
return DirOrFileName;
}
Replace ???? with std::string.
It doesn't work, I tried. I get "expected unqualified-id before '{' token"
expected ',' or ';' before '{' token
are you #including <string>?
post the code and mark the line that's giving you an error.
As pointed out already, get rid of the unexpected semicolon.Quote:
Originally Posted by bikr692002
Code:std::string GetObject(std::string Option);
{
std::string DirOrFileName;
std::cout<<"Please enter "<<Option;
getline(std::cin,DirOrFileName,'\n');
return DirOrFileName;
}
omg haha thanks, didnt see thatQuote:
Originally Posted by Dave_Sinkula