求帮忙找程序的error并让他能在vc++中运行。


这个网页中的代码,我复制下来之后粘贴在VC++,出现了这样的错误。怎么修改才能在VC++中运行呢?希望能把修改好之后的代码发出来。

--------------------Configuration: Cpp1 - Win32 Debug--------------------
Compiling...
Cpp1.cpp
c:\users\administrator\desktop\cpp1.cpp(46) : error C2065: 'assert' : undeclared identifier
c:\users\administrator\desktop\cpp1.cpp(599) : 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 acceptab
le conversion)
c:\users\administrator\desktop\cpp1.cpp(601) : 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 acceptab
le conversion)
c:\users\administrator\desktop\cpp1.cpp(602) : error C2676: binary '==' : 'class std::basic_string,class std::allocator >' does not define this operator or a conversion to a type acceptable to the predefined
operator
c:\users\administrator\desktop\cpp1.cpp(602) : error C2676: binary '==' : 'class std::basic_string,class std::allocator >' does not define this operator or a conversion to a type acceptable to the predefined
operator
执行 cl.exe 时出错.

Cpp1.exe - 1 error(s), 0 warning(s)

你比较了两个自定义类型的变量,用了比较运算符,然后没有重载对应的运算符,两个自定义的类型想要直接用==去比较, 需要自己去重载==运算符

 #include <assert.h> 了没有,看你的代码

Compiling...
Cpp1.cpp
c:\users\administrator\desktop\cpp1.cpp(167) : error C2676: binary '==' : 'class std::basic_string,class std::allocator >' does not define this operator or a conversion to a type acceptable to the predefined
operator
c:\users\administrator\desktop\cpp1.cpp(213) : error C2676: binary '==' : 'class std::basic_string,class std::allocator >' does not define this operator or a conversion to a type acceptable to the predefined
operator
c:\users\administrator\desktop\cpp1.cpp(215) : error C2676: binary '==' : 'class std::basic_string,class std::allocator >' does not define this operator or a conversion to a type acceptable to the predefined
operator
c:\users\administrator\desktop\cpp1.cpp(217) : error C2676: binary '==' : 'class std::basic_string,class std::allocator >' does not define this operator or a conversion to a type acceptable to the predefined
operator
c:\users\administrator\desktop\cpp1.cpp(219) : error C2676: binary '==' : 'class std::basic_string,class std::allocator >' does not define this operator or a conversion to a type acceptable to the predefined
operator
c:\users\administrator\desktop\cpp1.cpp(221) : error C2676: binary '==' : 'class std::basic_string,class std::allocator >' does not define this operator or a conversion to a type acceptable to the predefined
operator
c:\users\administrator\desktop\cpp1.cpp(232) : error C2676: binary '==' : 'class std::basic_string,class std::allocator >' does not define this operator or a conversion to a type acceptable to the predefined
operator
c:\users\administrator\desktop\cpp1.cpp(232) : error C2676: binary '==' : 'class std::basic_string,class std::allocator >' does not define this operator or a conversion to a type acceptable to the predefined
operator
c:\users\administrator\desktop\cpp1.cpp(232) : error C2676: binary '==' : 'class std::basic_string,class std::allocator >' does not define this operator or a conversion to a type acceptable to the predefined
operator
c:\users\administrator\desktop\cpp1.cpp(239) : error C2676: binary '==' : 'class std::basic_string,class std::allocator >' does not define this operator or a conversion to a type acceptable to the predefined
operator
c:\users\administrator\desktop\cpp1.cpp(250) : error C2065: 'sort' : undeclared identifier
c:\users\administrator\desktop\cpp1.cpp(600) : 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 acceptab
le conversion)
c:\users\administrator\desktop\cpp1.cpp(602) : 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 acceptab
le conversion)
c:\users\administrator\desktop\cpp1.cpp(603) : error C2676: binary '==' : 'class std::basic_string,class std::allocator >' does not define this operator or a conversion to a type acceptable to the predefined
operator
c:\users\administrator\desktop\cpp1.cpp(603) : error C2676: binary '==' : 'class std::basic_string,class std::allocator >' does not define this operator or a conversion to a type acceptable to the predefined
operator
执行 cl.exe 时出错.

Cpp1.exe - 1 error(s), 0 warning(s)

插入了之后是这样的。也不可以。

字符串比较用strcmp