convert 'std::vector<>::iterator {aka __gnu_cxx::__normal_iterator<*, std::vector<> >}' to '*' in in
来源:互联网 发布:mysql 大于小于转义 编辑:程序博客网 时间:2024/06/05 23:54
错误程序:
#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>::iterator {aka __gnu_cxx::__normal_iterator<A*, std::vector<A> >}' to 'A*' in initialization
错因:
it是vector<A>::iterator型的,而指针p是struct A型的,两者不能直接转换。
解决方法:
将A *p = it;改成A *p = &(*it);即可。*it是struct A型的。
- convert 'std::vector<>::iterator {aka __gnu_cxx::__normal_iterator<*, std::vector<> >}' to '*' in in
- no type named 'vector' in namespace std
- Chapter 5. std::vector in C++
- std::vector
- std vector
- std::vector
- std::vector
- std::vector
- std::vector
- std::vector
- std::vector
- std::vector
- std::vector
- std::vector
- How to convert std::string to LPCWSTR in C++ (Unicode)
- std::map与std::vector
- std::vector,std::deque,std…
- cocos2d::Vector与std::vector
- 微软:经调查88%的用户表示喜欢WP手机
- Ubuntu root
- C/C++:构建你自己的插件框架
- 设计模式-观察者模式,在各种对象之间划分清晰的界限
- Win32中的字符串(位,字符,字节,编码)
- convert 'std::vector<>::iterator {aka __gnu_cxx::__normal_iterator<*, std::vector<> >}' to '*' in in
- Picking the Right NoSQL Database Tool
- ARM Linux内核驱动异常定位方法分析--反汇编方式
- ASP连接MYSQL并读取数据
- ORACLE IS 和 AS 用法
- 使用FileZilla Server建立FTP服务
- linux 内核的链表操作(好文不得不转)
- 第一天:splash页面和防盗功能
- 解决ssh不能添加已访问的主机到信任列表的问题(Failed to add the host to the list of known hosts) .