![]() |
strings in C++
I've been trying to setup visual studio and have run into a problem getting strings to work.
Code:
// stringtest.cpp : Defines the entry point for the console application. |
Re: strings in C++
Just including <string> is not enough. After all, you might define a string type of your own. The string class, as declared by <string> lives in the std namespace. You will need to quality your references by using something like, std::string MyString = "ABC";, or, alternatively, place the statement, "using std::string;" ahead of any usage. You need to be careful with "using" directives. You particularly need to be careful with an all-encompassing statement such as, "using namespace std;".
If you import every name in the std namespace (or even those in just string), you increase your chances of clashes with names that you come up with for your own code. |
| All times are GMT +5.5. The time now is 18:03. |