⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 subject_14640.htm

📁 一些关于vc的问答
💻 HTM
字号:
<p>
序号:14640 发表者:浪子 发表日期:2002-09-10 07:17:11
<br>主题:在控制台泛型设计
<br>内容:各位高手 :我在控制台下用 vector 编程,代码如下:<BR><BR><BR>#include &lt;vector&gt;<BR>#include &lt;iostream.h&gt;<BR>//using namespace <BR><BR><BR>void main()<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;vector&lt; int &gt; ivec;<BR>&nbsp;&nbsp;&nbsp;&nbsp;cout&lt;&lt;"iVeceo&nbsp;&nbsp;ise"&lt;&lt;ivec.size();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cout&lt;&lt;"\ncapacity:"&lt;&lt;ivec.capacity()&lt;&lt;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 &lt;vector&gt;<BR>#include &lt;iostream.h&gt;<BR>#include &lt;string&gt;<BR>using namespace std;<BR><BR><BR><BR>void main()<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;vector&lt; int &gt; ivec;<BR>&nbsp;&nbsp;&nbsp;&nbsp;cout&lt;&lt;"iVeceo&nbsp;&nbsp;ise"&lt;&lt;ivec.size();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cout&lt;&lt;"\ncapacity:"&lt;&lt;ivec.capacity()&lt;&lt;endl;<BR>&nbsp;&nbsp;&nbsp;&nbsp;string s1("jj");<BR>//&nbsp;&nbsp;&nbsp;&nbsp;s1="jj";<BR>&nbsp;&nbsp;&nbsp;&nbsp;cout&lt;&lt;s1&lt;&lt;endl;<BR>}<BR><BR>错误如下:<BR> error C2679: binary '&lt;&lt;' : no operator defined which takes a right-hand operand of type 'class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt;' (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>内容:&lt;iostream.h&gt;改成&lt;iostream&gt;<BR>带有.h的是旧版的库,不支持模板,最好不要使用。<BR><BR>关于名空间,本站就有一篇介绍的文章,你可以找找看。另外,在MSDN的<BR>VC Documentation -&gt; Reference-&gt;C/C ++ Language and C++ Libarary-&gt;C++ Language Reference-&gt;Declarations-&gt;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 + -