possible implementations of casting in c++
- by lego69
I have this snippet of the code in my header:
class A {
private:
int player;
public:
A(int initPlayer = 0);
A(const A&);
A& operator=(const A&);
~A();
void foo() const;
friend int operator==(const A& i, const A& member) const;
};
implementation of the operator==
int operator==(const A& i, const A& member) const{
if(i.player == member.player){
return 1;
}
return 0;
}
and I need casting for this part of my code:
A *pa1 = new A(a2);
assert(i == *pa1);
i - is some int, which my function receives
I receive an error non-member function, How can I fix it? thanks in advance