🔒 Locked
Problems including string-class
Advertisement
Original Post
Hi,
I have Visual C++ 6.0 installed. I installed MSDN libraries afterwards (they should be included automatically into VC++ 6.0 once you do that, right?)
Anyway, I cant get the class "string" to work.
Including...
#include <string>
..or..
#include <string.h>
..or..
#include <cstring>
..doesnt make the following simple creation of a string-object to work..
string myString;
Any idea as to what might be wrong? Thanks
In addition, the necessary include line is:
#include <string>
______________________________________________________________
The Phoenix shall arise from the ashes... ThunderHawk -- ¦þ
MySite
______________________________________________________________
#include <string>
______________________________________________________________
The Phoenix shall arise from the ashes... ThunderHawk -- ¦þ
MySite
______________________________________________________________
Thanks guys
Still got a problem, unfortunately:
Is there any reason why this simple sample code should not work?
---------------------------------------
#include <iostream.h>
#include <string>
using namespace std;
void main(){
string word;
cout << "Enter word: ";
cin >> word;
cout << word;
}
----------------------------------------
I get the following 2 error-messages:
1) error C2679: binary ''>>'' : no operator defined which takes a right-hand operand of type ''class std::basic_string,class std::allocator >'' (or there is no acceptable conversion)
2) error C2679: binary ''<<'' : no operator defined which takes a right-hand operand of type ''class std::basic_string,class std::allocator
>'' (or there is no acceptable conversion)
Is there any reason why this simple sample code should not work?
---------------------------------------
#include <iostream.h>
#include <string>
using namespace std;
void main(){
string word;
cout << "Enter word: ";
cin >> word;
cout << word;
}
----------------------------------------
I get the following 2 error-messages:
1) error C2679: binary ''>>'' : no operator defined which takes a right-hand operand of type ''class std::basic_string
2) error C2679: binary ''<<'' : no operator defined which takes a right-hand operand of type ''class std::basic_string
>'' (or there is no acceptable conversion)
Thanks 
Btw, it seems that both iostream.h and iostream exists in the libraries.
How are they different (in general terms - .h vs non-.h files)?
Btw, it seems that both iostream.h and iostream exists in the libraries.
How are they different (in general terms - .h vs non-.h files)?
iostream.h is a non-standard header that was used before the standard came around to the creation of <iostream>. It's only included for backwards compatibility. You should try to use the standardized versions of headers whenever possible (99.9% of the time) to improve the portability of your code.
______________________________________________________________
The Phoenix shall arise from the ashes... ThunderHawk -- ¦þ
MySite
______________________________________________________________
[edited by - Thunder_Hawk on January 11, 2004 11:17:39 AM]
______________________________________________________________
The Phoenix shall arise from the ashes... ThunderHawk -- ¦þ
MySite
______________________________________________________________
[edited by - Thunder_Hawk on January 11, 2004 11:17:39 AM]
Great info - strings are working perfectly now.
Thanks again
Thanks again
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement