Original Post
I'm not sure if I'm doing this right: But trying this doesn't work: What am I doing wrong when overloading ==? It is a bool right?
#include <string>
class CStudent
{
public:
CStudent( std::string sName, int nClass, int nHouse )
{
this->m_sName = sName;
this->m_nClass = nClass;
this->m_nHouse = nHouse;
}
std::string m_sName;
int m_nClass;
int m_nHouse;
CStudent* pOpponent1;
CStudent* pOpponent2;
CStudent* pOpponent3;
CStudent* pOpponent4;
inline bool operator == (CStudent sOpponent)
{
if( this->m_sName == sOpponent.m_sName )
{
return true;
}
else
{
return false;
}
}
};
CStudent* one;
CStudent* two;
one = new CStudent( "Name", 1, 2 );
two = new CStudent( "Name", 1, 2 );
if( one == two )
{
MessageBox( NULL, "Equal", "", MB_OK);
}