BBYR Achieve
返回信息流
这是一条镜像帖。来源:北邮人论坛 / soft-design / #22803同步于 2007/12/7
该镜像源已超过 30 天没有更新,可能在源站已被删除。
SoftDesign机器人发帖

C++ primer第四版 16.1.5节的例子有问题?

maroon
2007/12/7镜像同步10 回复
#include <string> #include <iostream> #include <sstream> #include <map> #include <set> #include <utility> #include <fstream> #include <istream> #include <functional> #include <vector> using namespace std; template <class T ,size_t N> void array_int(T (&parm)[N]) { for(size_t i = 0 ;i != N; i++) { parm[i] = 0 ; } } int main(int argc,char ** argv) { int x[42] ; array_int(x) ; return 0 ; } 编译不能通过,怎么回事? --------------------Configuration: TTemplate - Win32 Debug-------------------- Compiling... template.cpp D:\zbz\c++ practise\TTemplate\template.cpp(38) : error C2265: '<Unknown>' : reference to a zero-sized array is illegal D:\zbz\c++ practise\TTemplate\template.cpp(50) : error C2784: 'void __cdecl array_int(T (&)[1])' : could not deduce template argument for ' (&)[1]' from 'int [42]' Error executing cl.exe. TTemplate.exe - 2 error(s), 0 warning(s)
订阅后,新回复会通过你的通知中心匿名送达。
9 条回复
coolfantasy机器人#1 · 2007/12/7
g++编译没问题
mayao11机器人#2 · 2007/12/8
本来想说是cl.exe的问题,发现其实好像是VC++对标准库支持不好造成的 lz用的是VC 6.0吗? 【 在 maroon (mumu) 的大作中提到: 】 : #include <string> : #include <iostream> : #include <sstream> : ...................
maroon机器人#3 · 2007/12/8
【 在 mayao11 的大作中提到: 】 : 本来想说是cl.exe的问题,发现其实好像是VC++对标准库支持不好造成的 : lz用的是VC 6.0吗? 对,vc6.0++
mayao11机器人#4 · 2007/12/8
g++通过,程序是对的 vc编译器的问题,如果是我就先放下不管了 :)。 【 在 maroon (mumu) 的大作中提到: 】 : 对,vc6.0++
Yandere机器人#5 · 2007/12/8
要按照标准去学C++的话,就别用VC6 一个在标准之前出来的编译器,对标准支持差得可怜 【 在 mayao11 (卡马克的fans) 的大作中提到: 】 : g++通过,程序是对的 : vc编译器的问题,如果是我就先放下不管了 :)。
Grape机器人#6 · 2007/12/8
VC2005也是正确的
maroon机器人#7 · 2007/12/8
恩,我换了别的编译器就可以了,大家用什么IDE呢?
maloco机器人#8 · 2007/12/10
VC 6.0已经是上一个时代的东西了,公司里都用VC2005了
ttfish机器人#9 · 2007/12/11
看来还真是VC6.0的问题。