VC中有vector类吗?怎么使用时报undeclared identifier? 已经有#include <vector>.vector和泛型是什么关系? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 vector 是 STL 的一部分 1楼已经说得很对了。楼主要使用vector 除了头文件之外,还要注意C++的命名空间。至于泛型是怎么回事,这个问题一句两句话很难说明白。不过如果楼主有意在C++方面上发展,应该先从C++的语法开始学习,先语法,再数据结构,再STL,然后你自然就会对泛型这个概念有深刻的理解了。仅仅是让别人说几句话来解释一个对你比较“前卫”的概念,对楼主的学习意义不大。// vector_begin.cpp// compile with: /EHsc#include <vector>#include <iostream>int main(){ using namespace std; vector<int> c1; vector<int>::iterator c1_Iter; vector<int>::const_iterator c1_cIter; c1.push_back(1); c1.push_back(2); cout << "The vector c1 contains elements:"; c1_Iter = c1.begin(); for (; c1_Iter != c1.end(); c1_Iter++) { cout << " " << *c1_Iter; } cout << endl; cout << "The vector c1 now contains elements:"; c1_Iter = c1.begin(); *c1_Iter = 20; for (; c1_Iter != c1.end(); c1_Iter++) { cout << " " << *c1_Iter; } cout << endl; // The following line would be an error because iterator is const // *c1_cIter = 200;} 时间控件返回时间错误时为什么? 屏幕取词是怎么实现的? 从文件打开对话框,选择一张BMP图象显示在指定区域,帮忙指点是不是这样写 通过域名怎么知道网站的IP和对应的端口呀 关于Vfw的函数ICDecompress()问题 我的位图保存有问题,请看一下。 VC屏幕坐标 关于MFC界面的问题,请指点。 求 Access violation reading location 0x00000024.解决方法 ★决定改用BCB和Delphi,VC把我搞晕了什么MFC、STL去死!★ 有关opengl的问题,请帮忙 _ConnectionPtr对象怎么即可以"."操作又可以"->"操作
至于泛型是怎么回事,这个问题一句两句话很难说明白。不过如果楼主有意在C++方面上发展,应该先从C++的语法开始学习,先语法,再数据结构,再STL,然后你自然就会对泛型这个概念有深刻的理解了。仅仅是让别人说几句话来解释一个对你比较“前卫”的概念,对楼主的学习意义不大。// vector_begin.cpp
// compile with: /EHsc
#include <vector>
#include <iostream>int main()
{
using namespace std;
vector<int> c1;
vector<int>::iterator c1_Iter;
vector<int>::const_iterator c1_cIter; c1.push_back(1);
c1.push_back(2); cout << "The vector c1 contains elements:";
c1_Iter = c1.begin();
for (; c1_Iter != c1.end(); c1_Iter++)
{
cout << " " << *c1_Iter;
}
cout << endl; cout << "The vector c1 now contains elements:";
c1_Iter = c1.begin();
*c1_Iter = 20;
for (; c1_Iter != c1.end(); c1_Iter++)
{
cout << " " << *c1_Iter;
}
cout << endl; // The following line would be an error because iterator is const
// *c1_cIter = 200;
}