bool Stock::operator== (const Stock& stk){
if ( this->get_resource() == (stk.get_resource()) )
return true;
else
return false;
}
I created this method to overload the operations of a class, however, when I instantiate pointers of this class and initialize them, I set values and see if one object is equal to the other method that should return TRUE
, since the values are the same, it does not return.
int main (){
Stock* stk1 = new Stock();
Stock* stk2 = new Stock();
stk1->set_resource(10);
stk2->set_resource(10);
cout << stk1->get_resource() << endl;
cout << stk2->get_resource() << endl;
if(stk1 == stk2)
cout << "IGUAL" << endl;
return 0;
}
if
never runs.