2012年12月19日

convert 'std::vector<>::iterator {aka __gnu_cxx::__normal_iterator<*, std::vector<> >}' to '*' in in

摘要: 错误程序:#include <iostream> #include <vector> using namespace std; struct A { int x; A(int y) {x = y;} }; int main() { A a(11217); vector<A> V; V.push_back(a); vector<A>::iterator it = V.begin(); A *p = it; return 0; }编译报错:error: cannot convert 'std::vector<A>::iterat. 阅读全文

posted @ 2012-12-19 18:47 铁树银花 阅读(1776) 评论(0) 推荐(0) 编辑

error: creating array of references( declaration of 'a' as array)

摘要: 错误程序:#include <iostream> using namespace std; void func(int& a[], int n) { for(int i = 0; i < n; i++) a[i]++; } int main() { int a[3] = {1, 2, 3}; func(a, 3); cout << a[0] << ' ' << a[1] << ' ' << a[2] << endl; return 0; } 初衷:通过建立引用型形参 阅读全文

posted @ 2012-12-19 17:02 铁树银花 阅读(329) 评论(0) 推荐(0) 编辑

导航