0

My struct is as follows:

struct pixel{

int val;
int x;
int y;

pixel(int v = 0, float l = 0, float h = 0)
{
    val = v;
    x = l;
    y = h;
}


 bool operator == (const pixel &p1, const pixel &p2)  //ERROR
{

     if(p1.val() == p2.val()) return true;
     else return false;

}


};

I have 2 pixels (12 ,0,1) and (66, 2 , 2) I want to compare if they have the same value which is 12 not equal 66

my main would be:

int main()
{
pixel b;
  b.val=12;
b.x=0;
b.y=1;

pixel c;
c.val=66;
  c.x=2;
 c.y=2;

 if(b==c) //ERROR
  { ///do sth
  }
return 0;
    }

error is in operator overloadin: too many parameters, it should take 1 pixel as parameter but how is it going to compare???

Maram
  • 37
  • 1
  • 1
  • 6

0 Answers0