error:no type named iterator_category in struct
来源:互联网 发布:查看域名真实ip 编辑:程序博客网 时间:2024/06/03 17:36
又一个非常非常诡异的一个编译错误。当我第一次遇到这个错误的时候头都晕了。还是先把代码贴上来吧:
- #include <iostream>
- #include <stdio.h>
- #include <math.h>
- using namespace std;
- typedef struct TagPoint
- {
- int x, y;
- }Point;
- inline double distance(const Point& a, const Point& b)
- {
- return sqrt((a.x - b.x)*(a.x - b.x) + (a.y - b.y)*(a.y - b.y));
- }
- int main(int argc, char **argv)
- {
- Point a, b;
- printf(”%lf\n”, distance(a, b));
- return 0;
- }
#include <iostream>
问题出在哪里呢?我们只是写了一段普通的代码,却爆出来一大堆STL相关的错误信息(STL的错误信息实在是太难看了)。后来仔细研究发现,是函数命名存在问题。猛然想起distance是STL中求迭代器距离的一个函数,这里冲突了。按理来说编译器应该可以推断出使用哪个函数吧~~也曾经遇到过类似的编译错误,有关transform函数的。
好啦,解决就是给distance换一个名字。附上编译错误信息:
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/stl_iterator_base_types.h: In instantiation of `std::iterator_traits':test.cpp:19: instantiated from hereC:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/stl_iterator_base_types.h:129: error: no type named `iterator_category' in `struct TagPoint'C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/stl_iterator_base_types.h:130: error: no type named `value_type' in `struct TagPoint'C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/stl_iterator_base_types.h:131: error: no type named `difference_type' in `struct TagPoint'C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/stl_iterator_base_types.h:132: error: no type named `pointer' in `struct TagPoint'C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/stl_iterator_base_types.h:133: error: no type named `reference' in `struct TagPoint'
0 0
- error:no type named iterator_category in struct
- error:no type named iterator_category in struct
- no type named `iterator_category' in `struct Pointt'
- C++编译错误no type named ‘iterator_category’ in ‘class Point’,distance重名
- error: no type named 'u16string' in namespace 'std'
- error: no type named 'u16string' in namespace 'std'
- no type named 'vector' in namespace std
- error: no type named 'string' in namespace 'std'; did you mean 'std::string'? [3]
- error: ‘struct device’ has no member named ‘bus_id’
- error: ‘struct device’ has no member named ‘bus_id’
- error: 'struct passwd' has no member named 'pw_comment'
- error: 'struct proc_dir_entry' has no member named 'owner'的解决方法
- error: ‘struct hostent’ has no member named ‘h_addr’
- error: ‘struct dentry’ has no member named ‘d_count’
- error: 'struct proc_dir_entry' has no member named 'owner'的解决方法
- error: ‘struct hostent’ has no member named ‘h_addr’
- The error in python :ImportError: No module named xxx
- php5.4.26 安装出现 error: ‘struct gdIOCtx’ has no member named ‘data’
- Shader编程学习笔记(三)—— 三大主流编程语言 HLSL/GLSL/Cg
- QT项目相关问题
- SpringBoot Demo(二)模板的渲染
- 高性能mysql之TIMESTAMP与DATETIME
- spring-代理
- error:no type named iterator_category in struct
- 多进程
- openstack git git-review
- 报头压缩-ROHC压缩系统
- VMware Tools 安装
- oracle rac 静默安装
- 红黑树的简单插入
- Python如何给矩阵加行或列?
- <mvc:annotation-driven/>与<mvc:default-servlet-handler/>之间的一个问题