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.
There are 10 types of people in this world, those who cringed when reading the beginning of this sentence and those who salivated to how superior they are for understanding something as simple as binary.
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.
"I saw a sign that said 'Drink Canada Dry', so I started"
-- Brendan Behan
Free Compiler: Visual C++ 2005 Express
If you program in C++, you need Boost. You should also know how to use the Standard Library (STL). Want to make games? After reading this, I don't like WxWidgets anymore. Want to add some scripting to your App?
As pointed out already, get rid of the unexpected semicolon.Originally Posted by bikr692002Code:std::string GetObject(std::string Option); { std::string DirOrFileName; std::cout<<"Please enter "<<Option; getline(std::cin,DirOrFileName,'\n'); return DirOrFileName; }
Last edited by Dave_Sinkula; 04-09-2006 at 04:30 PM.
7. It is easier to write an incorrect program than understand a correct one.
40. There are two ways to write error-free programs; only the third one works.*
omg haha thanks, didnt see thatOriginally Posted by Dave_Sinkula