error: passing const as 'this' argument of ... discards qualifiers..
I've been looking up how to fix this error, apparently it has to do with functions which should be declared const since something they take is const.
I have a base class, graphobj, which has subclasses triangle, quad, etc.
Each subclass calls a function, fill, which takes a few parameters, one of which is a Vector3f.
I'm getting this error:
graphobj.h: In member function ‘void GraphObj::fill(Image&, Vec3f&, Vec2f)’:
graphobj.h:13: error: passing ‘const Vec3f’ as ‘this’ argument of ‘int Vec3f::operator!=(const Vec3f&)’ discards qualifiers
This is the graphobj code:
Code:
#ifndef _GRAPHOBJ_H_
#define _GRAPHOBJ_H_
#include "image.h"
// GraphObj
class GraphObj {
public:
virtual ~GraphObj();
virtual void draw(Image& i) = 0;
void fill(Image& i, Vec3f& color, Vec2f point) {
if(i.GetPixel((int)point.x(),(int)point.y()) != color){
i.SetPixel((int)point.x(),(int)point.y(),color);
fill(i,color,Vec2f(point.x()+1,point.y()+1));
fill(i,color,Vec2f(point.x()-1,point.y()+1));
fill(i,color,Vec2f(point.x()+1,point.y()-1));
fill(i,color,Vec2f(point.x()-1,point.y()-1));
}
}
};
#endif
There are quite a few supporting files, I don't want to attach all of them and make this unreadable. If I need to include more information to figure this out, just tell me.
How do I solve this issue?? Thanks!