|
-
Tiger Shark
Declaring Strings in C++
Why when I declare a string in Visual C++ 6.0 like this:
string userDollars = "";
the word string doesn't show in blue like all other keywords? I think it should, and it's not, making me think it's not actually letting me declare a string. And yes I did #include <string>
Thanks!!
-
Because string isn't a primitive data type its actually an array of characters char[]. To my knowledge Microsoft visual C++ doesn't highlight classes. Therefore, most classes will not be in blue(I've yet to see one that hasn't.)
-
Tiger Shark
Ok, that makes sense, but relative to that, look at this:
checkCharacter.assign(userInput, count, 1);
checkCharacter is defined as a char, userInput is defined as a string. I thought this statement should give checkCharacter the count'th letter in the userInput, but I get an error:
error C2228: left of '.assign' must have class/struct/union type
I don't get what is wrong here..
-
how is checkCharacter orginally declared?
-
Tiger Shark
It was originally declared as a char. But after I wrote that last post, I changed all references to it to a string instead. I guess comparing a string of one character would be just as easy as comparing a char, and now my errors went away. Thanks for putting me on the right track!!
-
Registered User
Originally posted by Frostburn
Because string isn't a primitive data type its actually an array of characters char[]. To my knowledge Microsoft visual C++ doesn't highlight classes. Therefore, most classes will not be in blue(I've yet to see one that hasn't.)
because string is a c++ class. ie.. char is a varibal.
Last edited by peterlak; 12-19-2002 at 09:48 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|