我写了一个头文件,把用到的模板类和模板类的实现都放在里面,
然后cpp文件里只放了个main,但我的模板类里多了个cout<<,不引用头文件"stdlib.h"
编译错误,请看
------------------Configuration: Eptr - Win32 Debug--------------------
Compiling...
Expr.cpp
e:\mydoc\c++\eptr\expr.h(177) : error C2065: 'cout' : undeclared identifier
e:\mydoc\c++\eptr\expr.h(14) : while compiling class-template member function 'void __thiscall List<char>::Print(void)'
e:\mydoc\c++\eptr\expr.h(177) : warning C4552: '<<' : operator has no effect; expected operator with side-effect
e:\mydoc\c++\eptr\expr.h(14) : while compiling class-template member function 'void __thiscall List<char>::Print(void)'
Error executing cl.exe.Eptr.exe - 1 error(s), 1 warning(s)当我引用了stdlib.h后,报这样的错误
-Configuration: Eptr - Win32 Debug--------------------
Compiling...
Expr.cpp
Linking...
LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
Debug/Eptr.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.Eptr.exe - 2 error(s), 0 warning(s)
然后cpp文件里只放了个main,但我的模板类里多了个cout<<,不引用头文件"stdlib.h"
编译错误,请看
------------------Configuration: Eptr - Win32 Debug--------------------
Compiling...
Expr.cpp
e:\mydoc\c++\eptr\expr.h(177) : error C2065: 'cout' : undeclared identifier
e:\mydoc\c++\eptr\expr.h(14) : while compiling class-template member function 'void __thiscall List<char>::Print(void)'
e:\mydoc\c++\eptr\expr.h(177) : warning C4552: '<<' : operator has no effect; expected operator with side-effect
e:\mydoc\c++\eptr\expr.h(14) : while compiling class-template member function 'void __thiscall List<char>::Print(void)'
Error executing cl.exe.Eptr.exe - 1 error(s), 1 warning(s)当我引用了stdlib.h后,报这样的错误
-Configuration: Eptr - Win32 Debug--------------------
Compiling...
Expr.cpp
Linking...
LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
Debug/Eptr.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.Eptr.exe - 2 error(s), 0 warning(s)
方法一。去掉这两个宏。
方法二。project-〉setting 在link 页入口点(在IMPORT还是OUTPUT中我忘记了)输入:wWinMainCRTStartup