控制台程序使用<Afxtempl.h>出错,怎么解决?
- C/C++ code
#include<iostream>#include <Afxtempl.h>using namespace std;class Car{public: void setLen(int len){ c_lenth = len; } void setWid(int wid){ c_width = wid; } int getLen(){ return c_lenth; } int getWid(){ return c_width; }private: int c_lenth; int c_width;};void main(){ int i=10; cout << i;}为什么include<Afxtempl.h>,cout语句就无法使用?如何解决?
错误信息:
1>nafxcw.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new[](unsigned int)" (??_U@YAPAXI@Z) 已经在 libcpmt.lib(newaop.obj) 中定义
1>E:\运动目标分类\目标分类代码版本\毕业设计实验\test\Debug\test.exe : fatal error LNK1169: 找到一个或多个多重定义的符号
[解决办法]
如果要使用mfc的类 就用mfc程序 用控制台引用mfc的类 有可能会出异常