请帮忙看看这个程序,谢谢

noahnoah 2003-07-16 02:06:14
#include <iostream>
using namespace std;

template<typename T>
class Array {
enum{ size = 100 };
T A[size];
public :
T& operator[](int index) {
if(index >= 0 && index < size)
return A[index];
else
return A[0];
}
};

int main()
{
Array<int> ia;
Array<float> fa;

for(int i = 0;i < 20;i++) {
ia[i] = i*i;
fa[i] = i + 1.414;
}
for(i = 0;i < 20;i++)
cout<<i<<": "<<ia[i]
<<","<<fa[i]<<endl;
return 0;
}
在vc6下linking时出错:

LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
Debug/STLTemplate.exe : fatal error LNK1120: 1 unresolved externals

不知何故,请指教。
谢谢。
...全文
25 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
noahnoah 2003-07-17
  • 打赏
  • 举报
回复
确实是win32 console application
vc偶做过不少windows小程序,没用vc做过STL方面的东西,vc可以在dos下编译调试程序?
具体怎么做?
mu_gong 2003-07-17
  • 打赏
  • 举报
回复
搂主在dos下调试一下,配置一下环境变量
看来搂主对vc的ide不是很熟悉么
98440622 2003-07-17
  • 打赏
  • 举报
回复
楼主用的是Win32 Application吧,如果你坚持的话,可以将连接参数的/subsystem:windows改成/subsystem:console就可以了。
或者干脆就用Win32 console application
noahnoah 2003-07-17
  • 打赏
  • 举报
回复
ft. 刚才才发现是搞错了。
98440622(民工++) 兄说得对。
noahnoah 2003-07-16
  • 打赏
  • 举报
回复
控制台程序:
win32 console application
GZCompiler 2003-07-16
  • 打赏
  • 举报
回复
你建的什么工程?
noahnoah 2003-07-16
  • 打赏
  • 举报
回复
如题。
noahnoah 2003-07-16
  • 打赏
  • 举报
回复
如题。

24,854

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 工具平台和程序库
社区管理员
  • 工具平台和程序库社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧