RE: error: no match for `std::string& != long int' operator

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Sorry, but you code is wrong.
string is a class name and s1 is an object.
You can't apply != NULL or ++ unless 
these operators are declared by basic_string.
As far as I know basic_string doesn't have those operators.

-----Original Message-----
From: gcc-help-owner@xxxxxxxxxxx [mailto:gcc-help-owner@xxxxxxxxxxx]On
Behalf Of learning c++
Sent: Wednesday, September 01, 2004 2:23 PM
To: gcc-help@xxxxxxxxxxx
Subject: error: no match for `std::string& != long int' operator


Hi,
I have a short code hope to print the character of a string one by one. but 
there are some errors.

if I declare srting s1, is s1 a pointer? are there some difference between C 
and C++?
#include <iostream>
#include <string>

using namespace std;

int main(){

string s1("0123456789abcdefghijklmnopqrstuvwxyz");
for(s1; s1!=NULL; ++s1)
cout <<*s1<<" " <<int(*s1)<<"  ";

return 0;

}
printc.cpp: In function `int main()':
printc.cpp:9: error: no match for `std::string& != long int' operator
printc.cpp:9: error: no match for `++ std::string&' operator
printc.cpp:10: error: no match for `* std::string&' operator
printc.cpp:10: error: no match for `* std::string&' operator
printc.cpp:9: warning: statement with no effect

_________________________________________________________________
The new MSN 8: advanced junk mail protection and 2 months FREE* 
http://join.msn.com/?page=features/junkmail



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux