ďťż

Ładny brzuch

W Visual C++ 2008 Express Edition gdy piszę
string s1, s2; s1 == s2;
to wywala mnóstwo błędów, że, zdaje się, nie ma zdefiniowanego operatora == dla stringów. W DevC++ ten kod działa.
Czy to wynika z innej wersji biblioteki iostream w Visualu? jeśli tak to czy mogę zmienić bibliotekę z visuala na tę z devc++? Jak to zrobić?



pokaz caly kod i te błedy

// tmp.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <iostream> using namespace std; int _tmain(int argc, _TCHAR* argv[]) { string a, b; a == b; system("PAUSE"); return 0; }

błędy:
1>------ Build started: Project: tmp, Configuration: Release Win32 ------ 1>Compiling... 1>tmp.cpp 1>.\tmp.cpp(13) : error C2784: 'bool std::operator ==(const std::istreambuf_iterator<_Elem,_Traits> &,const std::istreambuf_iterator<_Elem,_Traits> &)' : could not deduce template argument for 'const std::istreambuf_iterator<_Elem,_Traits> &' from 'std::string' 1> D:\Program Files\Microsoft Visual Studio 9.0\VC\include\streambuf(548) : see declaration of 'std::operator ==' 1>.\tmp.cpp(13) : error C2784: 'bool std::operator ==(const std::istreambuf_iterator<_Elem,_Traits> &,const std::istreambuf_iterator<_Elem,_Traits> &)' : could not deduce template argument for 'const std::istreambuf_iterator<_Elem,_Traits> &' from 'std::string' 1> D:\Program Files\Microsoft Visual Studio 9.0\VC\include\streambuf(548) : see declaration of 'std::operator ==' 1>.\tmp.cpp(13) : error C2784: 'bool std::operator ==(const std::istreambuf_iterator<_Elem,_Traits> &,const std::istreambuf_iterator<_Elem,_Traits> &)' : could not deduce template argument for 'const std::istreambuf_iterator<_Elem,_Traits> &' from 'std::string' 1> D:\Program Files\Microsoft Visual Studio 9.0\VC\include\streambuf(548) : see declaration of 'std::operator ==' 1>.\tmp.cpp(13) : error C2784: 'bool std::operator ==(const std::istreambuf_iterator<_Elem,_Traits> &,const std::istreambuf_iterator<_Elem,_Traits> &)' : could not deduce template argument for 'const std::istreambuf_iterator<_Elem,_Traits> &' from 'std::string' 1> D:\Program Files\Microsoft Visual Studio 9.0\VC\include\streambuf(548) : see declaration of 'std::operator ==' 1>.\tmp.cpp(13) : error C2784: 'bool std::operator ==(const std::allocator<_Ty> &,const std::allocator<_Other> &) throw()' : could not deduce template argument for 'const std::allocator<_Ty> &' from 'std::string' 1> D:\Program Files\Microsoft Visual Studio 9.0\VC\include\xmemory(173) : see declaration of 'std::operator ==' 1>.\tmp.cpp(13) : error C2784: 'bool std::operator ==(const std::allocator<_Ty> &,const std::allocator<_Other> &) throw()' : could not deduce template argument for 'const std::allocator<_Ty> &' from 'std::string' 1> D:\Program Files\Microsoft Visual Studio 9.0\VC\include\xmemory(173) : see declaration of 'std::operator ==' 1>.\tmp.cpp(13) : error C2784: 'bool std::operator ==(const std::allocator<_Ty> &,const std::allocator<_Other> &) throw()' : could not deduce template argument for 'const std::allocator<_Ty> &' from 'std::string' 1> D:\Program Files\Microsoft Visual Studio 9.0\VC\include\xmemory(173) : see declaration of 'std::operator ==' 1>.\tmp.cpp(13) : error C2784: 'bool std::operator ==(const std::allocator<_Ty> &,const std::allocator<_Other> &) throw()' : could not deduce template argument for 'const std::allocator<_Ty> &' from 'std::string' 1> D:\Program Files\Microsoft Visual Studio 9.0\VC\include\xmemory(173) : see declaration of 'std::operator ==' 1>.\tmp.cpp(13) : error C2784: 'bool std::operator ==(const std::reverse_iterator<_RanIt> &,const std::reverse_iterator<_RanIt2> &)' : could not deduce template argument for 'const std::reverse_iterator<_RanIt> &' from 'std::string' 1> D:\Program Files\Microsoft Visual Studio 9.0\VC\include\xutility(2220) : see declaration of 'std::operator ==' 1>.\tmp.cpp(13) : error C2784: 'bool std::operator ==(const std::reverse_iterator<_RanIt> &,const std::reverse_iterator<_RanIt2> &)' : could not deduce template argument for 'const std::reverse_iterator<_RanIt> &' from 'std::string' 1> D:\Program Files\Microsoft Visual Studio 9.0\VC\include\xutility(2220) : see declaration of 'std::operator ==' 1>.\tmp.cpp(13) : error C2784: 'bool std::operator ==(const std::reverse_iterator<_RanIt> &,const std::reverse_iterator<_RanIt2> &)' : could not deduce template argument for 'const std::reverse_iterator<_RanIt> &' from 'std::string' 1> D:\Program Files\Microsoft Visual Studio 9.0\VC\include\xutility(2220) : see declaration of 'std::operator ==' 1>.\tmp.cpp(13) : error C2784: 'bool std::operator ==(const std::reverse_iterator<_RanIt> &,const std::reverse_iterator<_RanIt2> &)' : could not deduce template argument for 'const std::reverse_iterator<_RanIt> &' from 'std::string' 1> D:\Program Files\Microsoft Visual Studio 9.0\VC\include\xutility(2220) : see declaration of 'std::operator ==' 1>.\tmp.cpp(13) : error C2784: 'bool std::operator ==(const std::_Revranit<_RanIt,_Base> &,const std::_Revranit<_RanIt2,_Base2> &)' : could not deduce template argument for 'const std::_Revranit<_RanIt,_Base> &' from 'std::string' 1> D:\Program Files\Microsoft Visual Studio 9.0\VC\include\xutility(2024) : see declaration of 'std::operator ==' 1>.\tmp.cpp(13) : error C2784: 'bool std::operator ==(const std::_Revranit<_RanIt,_Base> &,const std::_Revranit<_RanIt2,_Base2> &)' : could not deduce template argument for 'const std::_Revranit<_RanIt,_Base> &' from 'std::string' 1> D:\Program Files\Microsoft Visual Studio 9.0\VC\include\xutility(2024) : see declaration of 'std::operator ==' 1>.\tmp.cpp(13) : error C2784: 'bool std::operator ==(const std::_Revranit<_RanIt,_Base> &,const std::_Revranit<_RanIt2,_Base2> &)' : could not deduce template argument for 'const std::_Revranit<_RanIt,_Base> &' from 'std::string' 1> D:\Program Files\Microsoft Visual Studio 9.0\VC\include\xutility(2024) : see declaration of 'std::operator ==' 1>.\tmp.cpp(13) : error C2784: 'bool std::operator ==(const std::_Revranit<_RanIt,_Base> &,const std::_Revranit<_RanIt2,_Base2> &)' : could not deduce template argument for 'const std::_Revranit<_RanIt,_Base> &' from 'std::string' 1> D:\Program Files\Microsoft Visual Studio 9.0\VC\include\xutility(2024) : see declaration of 'std::operator ==' 1>.\tmp.cpp(13) : error C2784: 'bool std::operator ==(const std::pair<_Ty1,_Ty2> &,const std::pair<_Ty1,_Ty2> &)' : could not deduce template argument for 'const std::pair<_Ty1,_Ty2> &' from 'std::string' 1> D:\Program Files\Microsoft Visual Studio 9.0\VC\include\utility(68) : see declaration of 'std::operator ==' 1>.\tmp.cpp(13) : error C2784: 'bool std::operator ==(const std::pair<_Ty1,_Ty2> &,const std::pair<_Ty1,_Ty2> &)' : could not deduce template argument for 'const std::pair<_Ty1,_Ty2> &' from 'std::string' 1> D:\Program Files\Microsoft Visual Studio 9.0\VC\include\utility(68) : see declaration of 'std::operator ==' 1>.\tmp.cpp(13) : error C2784: 'bool std::operator ==(const std::pair<_Ty1,_Ty2> &,const std::pair<_Ty1,_Ty2> &)' : could not deduce template argument for 'const std::pair<_Ty1,_Ty2> &' from 'std::string' 1> D:\Program Files\Microsoft Visual Studio 9.0\VC\include\utility(68) : see declaration of 'std::operator ==' 1>.\tmp.cpp(13) : error C2784: 'bool std::operator ==(const std::pair<_Ty1,_Ty2> &,const std::pair<_Ty1,_Ty2> &)' : could not deduce template argument for 'const std::pair<_Ty1,_Ty2> &' from 'std::string' 1> D:\Program Files\Microsoft Visual Studio 9.0\VC\include\utility(68) : see declaration of 'std::operator ==' 1>.\tmp.cpp(13) : error C2676: binary '==' : 'std::string' does not define this operator or a conversion to a type acceptable to the predefined operator 1>Build log was saved at "file://c:\Documents and Settings\Betonowy Łukasz\Moje dokumenty\Visual Studio 2008\Projects\tmp\tmp\Release\BuildLog.htm" 1>tmp - 21 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

include stringa oczywiscie masz w stdafx.h?



O.O Ale co chcesz osiągnąć tym kodem? On jest bez sensu!
//
Aaa - znaczy się wogóle nie działa...
Użytkownik Radek edytował ten post 04 styczeń 2008, 01:34
http://cplusplus.com.../string/string/
Nie widzę nigdzie operatora ==. Do porównywania jest funkcja compare z tego co widzę...


include stringa oczywiscie masz w stdafx.h?

hehe, słuszna uwaga :) teraz działa :P


http://cplusplus.com.../string/string/
Nie widzę nigdzie operatora ==. Do porównywania jest funkcja compare z tego co widzę...

Operator jest jak byk tam zapisany, a funkcja compare jest odpowiednikiem strcmp z stdlib, więc jak ktoś chce to może sobie nawet porównywać długości stringów :P.

  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • zsf.htw.pl
  •