August 14th, 2003, 01:13 PM
VC++ does not accept string:clear method?
I'm surprised to see that Visual C++ does not accept clear as a valid method for strings. Gcc accepts it and the MSDN documentation accepts it as a method for basic_string (doesn't it mean that is also valid for string?)
August 14th, 2003, 02:10 PM
I'm surprised too (using Visual C++ 6.0 Enterprise Edition). But you can always use erase() instead:
string s("Hello world");
August 14th, 2003, 03:46 PM
MSDN does not list clear() as a member function of the template class basic_string. And other sources such as:
do not list clear() as a function of the string class.
I went to this page in MSDN:
typedef basic_string<char> string;
The type describes a specialization of template class basic_string for elements of type char.
and I clicked on the link for basic_string, and I looked down the list of function definitions in the class and there is no function with the name clear()--at least with my version that's the case.
Last edited by 7stud; August 14th, 2003 at 03:56 PM.
August 14th, 2003, 04:39 PM
The C++ standard is a much better reference than either of those, and includes clear().
Note that VC++ 6.0 is some way short of the C++ standard.
cppreference.com is clearly lacking.
August 14th, 2003, 06:48 PM
August 14th, 2003, 07:19 PM
Which version of VC++ are you using? Different versions will, obviously, have different functionality.
August 14th, 2003, 11:52 PM
"The C++ standard is a much better reference than either of those..."
What, are you being coy? How about a link?
August 15th, 2003, 02:20 AM
Thats because MS wants you to use MFC CStrings and 'Empty'.
The essence of Christianity is told us in the Garden of Eden history. The fruit that was forbidden was on the Tree of Knowledge. The subtext is, All the suffering you have is because you wanted to find out what was going on. You could be in the Garden of Eden if you had just kept your f***ing mouth shut and hadn't asked any questions.
August 15th, 2003, 03:26 AM
LOL, no, not being coy. As far as I know the standard isn't officially available on the internet for free. It can be bought in electronic (PDF) format for $18 from:
You may find illegal PDF copies on the internet from time to time, who knows, but for only $18 ...
There are copies of the draft version of the standard prior to the final version floating around on the internet freely available. Although there are differences between the October 1997 draft and the final standard, the differences are actually very small. If you don't want to pay $18, the draft is good enough. Again, a search on Google will throw up some links, but I did stumble across an HTML version here:
I can't vouch for the quality of information at that site as I haven't personally used it.
I would recommend a good C++ reference book over the standard though, for most purposes. The standard itself is very dry and requires interpretation. For the C++ language itself Stroustrup's The C++ Programming Language is very good (but not a beginner's book). For the standard library, The C++ Standard Library, A Tutorial and Reference by Jossutis is very good.
That said, you still need to refer to your compiler documentation for implementation defined details and compiler specific extensions.
Well certainly VC++ 6.0 predates the final standard and therefore doesn't claim to implement the final standard, so you will find some differences. VC++ 7 (.NET) is supposed to be far more standard compliant. I don't think there's a desire on their part to force people to use CStrings.
August 15th, 2003, 06:21 AM