Hello Guys,
I am trying to implement a coparison operator == into a try catch block to compare to clocks. I defined my comparator as
friend bool operator ==(Clock&c1,Clock&c2)
{
return(c1.get_hour()==c2.get_hour() && c1.get_minute()==c2.get_minute());
}
and my try catch block as
Clock *clock3;
try{
int hour,minute;
cout<<"Hour: ";
cin>>hour;
cout<<"Minute: ";
cin>>minute;
cout<<endl;
clock3= new Clock(hour,minute);
if(&clock2==clock3) // Clock clock2(8,30);
{throw 'a';}
}
catch(char a)
{
cout<<"same time"<<endl;
}
For some reason it is unable to compare clock2 and clock3. Any suggestions? :) Thanks a lot!