C
cppaddict
My initial method sig was:
bool NativeOcr::testPoints(Point positionCoords, std::map<Point,
COLORREF> testPnts) const ;
I changed it to:
bool NativeOcr::testPoints(const Point& positionCoords, const
std::map<Point, COLORREF>& testPnts) const ;
Whereas before it compiled, now it errors on the line marked below
(excerpt from method body):
std::map<Point, COLORREF>::iterator iter;
int x,y;
//ERROR ON NEXT LINE
for (iter = testPnts.begin(); iter != testPnts.end(); ++iter) {
//do stuff
}
I thought you could use refs just like the regular variable.
According the FAQ at:
http://www.parashift.com/c++-faq-lite/references.html
"please do not think of a reference as a funny looking pointer to an
object. A reference is the object. It is not a pointer to the object,
nor a copy of the object. It is the object."
Why does this not apply here?
Thanks for an explanation,
cpp
-----------------ERROR MESSAGE---------------
Error E2034 NativeOcr.cpp 494: Cannot convert
'__rwstd::__rb_tree<Point,std:
ai
r<const Point,unsigned long>,__rwstd::__select1st<std:
air<const
Point,unsigned
long>,Point>,std::less<Point>,std::allocator<std:
air<const
Point,unsigned lon
g> > >::const_iterator' to '__rwstd::__rb_tree<Point,std:
air<const
Point,unsig
ned long>,__rwstd::__select1st<std:
air<const Point,unsigned
long>,Point>,std::
std::map<Point,unsigned lon
nst
Error E2094 NativeOcr.cpp 494: 'operator!=' not implemented in type
'__rwstd::__
rb_tree<Point,std:
air<const Point,unsigned
long>,__rwstd::__select1st<std:
ai
r<const Point,unsigned
long>,Point>,std::less<Point>,std::allocator<std:
air<co
nst Point,unsigned long> > >::iterator' for arguments of type
'__rwstd::__rb_tre
e<Point,std:
air<const Point,unsigned
long>,__rwstd::__select1st<std:
air<cons
t Point,unsigned
long>,Point>,std::less<Point>,std::allocator<std:
air<const Po
int,unsigned long> > >::const_iterator' in function
NativeOcr::testPoints(const
Point &,const std::map<Point,unsigned
long,std::less<Point>,std::allocator<std::
pair<const Point,unsigned long> > > &) const
*** 2 errors in Compile ***
make: *** [NativeOcr.obj] Error 1
bool NativeOcr::testPoints(Point positionCoords, std::map<Point,
COLORREF> testPnts) const ;
I changed it to:
bool NativeOcr::testPoints(const Point& positionCoords, const
std::map<Point, COLORREF>& testPnts) const ;
Whereas before it compiled, now it errors on the line marked below
(excerpt from method body):
std::map<Point, COLORREF>::iterator iter;
int x,y;
//ERROR ON NEXT LINE
for (iter = testPnts.begin(); iter != testPnts.end(); ++iter) {
//do stuff
}
I thought you could use refs just like the regular variable.
According the FAQ at:
http://www.parashift.com/c++-faq-lite/references.html
"please do not think of a reference as a funny looking pointer to an
object. A reference is the object. It is not a pointer to the object,
nor a copy of the object. It is the object."
Why does this not apply here?
Thanks for an explanation,
cpp
-----------------ERROR MESSAGE---------------
Error E2034 NativeOcr.cpp 494: Cannot convert
'__rwstd::__rb_tree<Point,std:
r<const Point,unsigned long>,__rwstd::__select1st<std:
Point,unsigned
long>,Point>,std::less<Point>,std::allocator<std:
Point,unsigned lon
g> > >::const_iterator' to '__rwstd::__rb_tree<Point,std:
Point,unsig
ned long>,__rwstd::__select1st<std:
long>,Point>,std::
n function NativeOcr::testPoints(const Point &,constless said:::iterator' i
std::map<Point,unsigned lon
nst
Error E2094 NativeOcr.cpp 494: 'operator!=' not implemented in type
'__rwstd::__
rb_tree<Point,std:
long>,__rwstd::__select1st<std:
r<const Point,unsigned
long>,Point>,std::less<Point>,std::allocator<std:
nst Point,unsigned long> > >::iterator' for arguments of type
'__rwstd::__rb_tre
e<Point,std:
long>,__rwstd::__select1st<std:
t Point,unsigned
long>,Point>,std::less<Point>,std::allocator<std:
int,unsigned long> > >::const_iterator' in function
NativeOcr::testPoints(const
Point &,const std::map<Point,unsigned
long,std::less<Point>,std::allocator<std::
pair<const Point,unsigned long> > > &) const
*** 2 errors in Compile ***
make: *** [NativeOcr.obj] Error 1