hello, while I was using msvc I could use a referance and actual object interchangably however when I switch to g++ 4x, I start getting no match for ... kind of errors, here is a stuation
ImageDataPtr& operator= (ImageDataPtr& p) {
if(ptr != p.ptr) {
dispose();
ptr = p.getPtr();
count = p.getCount();
++*count;
}
return *this;
}
ImageDataPtr copyImage(ImageData* bitmap, Vec4 box);
ImageDataPtr lenaImgPtr(c.decode(lena));
/* this line cause a no match error because copyImage returns ImgDataPtr
* however, there is only one "=" operator in ImgDataPtr which takes ImgDataPtr&
*/
lenaImgPtr = c.copyImage(lenaImgPtr.getPtr(), Vec4(0,0,400,400));
this kind of usage was valid for mscv and seems correct to me as well :) saves me from writing same thing
If you want that your method works with constant objects, add const at the end of the definition
1 2 3 4 5 6
class A{
void foo(); //this two methods are actually distinct
void foo() const; //this will be called only with constants objects
void bar() const; //this is called by both
void foobar(); //this can't be called by a constant object
}
However, why you need a getter if you variable is public?