C++ reference variables
- by avd
I have these two functions (with Point2D & LineVector (has 2 Point2D member variables) classes and SQUARE macro predefined)
inline float distance(const Point2D &p1,const Point2D &p2) {
return sqrt(SQUARE(p2.getX()-p1.getX())+SQUARE(p2.getY()-p1.getY()));
}
inline float maxDistance(const LineVector &lv1,const LineVector &lv2) {
return max(distance(lv1.p1,lv2.p2),distance(lv1.p2,lv2.p1));
}
but it gives compilation error in maxDistance() function (line 238) saying:
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/stl_iterator_base_types.h: In instantiation of `std::iterator_traits<Point2D>':
quadrilateral.cpp:238: instantiated from here
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/stl_iterator_base_types.h:129: error: no type named `iterator_category' in `class
Point2D'
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/stl_iterator_base_types.h:130: error: no type named `value_type' in `class Point2D
'
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/stl_iterator_base_types.h:131: error: no type named `difference_type' in `class Point2D'
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/stl_iterator_base_types.h:132: error: no type named `pointer' in `class Point2D'
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/stl_iterator_base_types.h:133: error: no type named `reference' in `class Point2D'
Please suggest what is the error?