📄 subject_14640.htm
字号:
<p>
序号:14640 发表者:浪子 发表日期:2002-09-10 07:17:11
<br>主题:在控制台泛型设计
<br>内容:各位高手 :我在控制台下用 vector 编程,代码如下:<BR><BR><BR>#include <vector><BR>#include <iostream.h><BR>//using namespace <BR><BR><BR>void main()<BR>{<BR> vector< int > ivec;<BR> cout<<"iVeceo ise"<<ivec.size();<BR> cout<<"\ncapacity:"<<ivec.capacity()<<endl;<BR>}<BR><BR>它说,如下错误:<BR><BR>error C2065: 'vector' : undeclared identifier<BR>E:\97\56\5.cpp(8) : error C2062: type 'int' unexpected<BR>E:\97\56\5.cpp(9) : error C2065: 'ivec' : undeclared identifier<BR>E:\97\56\5.cpp(9) : error C2228: left of '.size' must have class/struct/union type<BR>E:\97\56\5.cpp(10) : error C2228: left of '.capacity' must have class/struct/union type<BR>Error executing cl.exe.<BR><BR>不知是什么原因。请指点。
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:史列因 回复日期:2002-09-10 07:35:31
<br>内容:using namespace std;<BR><BR><BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:浪子 回复日期:2002-09-10 21:53:29
<br>内容:to 史列因 :非常感谢你.我又要麻烦你帮助了。对于string 又不行了。代码如下:<BR><BR>#include <vector><BR>#include <iostream.h><BR>#include <string><BR>using namespace std;<BR><BR><BR><BR>void main()<BR>{<BR> vector< int > ivec;<BR> cout<<"iVeceo ise"<<ivec.size();<BR> cout<<"\ncapacity:"<<ivec.capacity()<<endl;<BR> string s1("jj");<BR>// s1="jj";<BR> cout<<s1<<endl;<BR>}<BR><BR>错误如下:<BR> error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' (or there is no acceptable conversion)<BR>Error executing cl.exe.<BR>在请你帮我一下,好吗?<BR>另外,对于名字空间,我还是有点弄不清楚,如果你有空的话,请你帮我解释一下,真的非常感谢你,我虽然学VC有几个月时间,但还是菜鸟一个。还需你等高手帮助。
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:史列因 回复日期:2002-09-11 08:34:24
<br>内容:<iostream.h>改成<iostream><BR>带有.h的是旧版的库,不支持模板,最好不要使用。<BR><BR>关于名空间,本站就有一篇介绍的文章,你可以找找看。另外,在MSDN的<BR>VC Documentation -> Reference->C/C ++ Language and C++ Libarary->C++ Language Reference->Declarations->Namespace里有完整的介绍<BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:浪子 回复日期:2002-09-11 17:55:36
<br>内容:真神了。谢谢你史列因 。
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -