指针遍历vector向量
#include <iostream> #include <vector> using namespace std; int main() { int a[] = {1,2,3,4}; vector<int>num(a,a+4); vector<int> *p = # for(int i=0;i<num.size();i++) cout<<(*p)[i]<<endl; }
Keep it simple!
#include <iostream> #include <vector> using namespace std; int main() { int a[] = {1,2,3,4}; vector<int>num(a,a+4); vector<int> *p = # for(int i=0;i<num.size();i++) cout<<(*p)[i]<<endl; }