Interview Question 3587

Created by admin on Sat, 17/11/2012 - 13:12
Explanation: 
Just like normal functions, operator functions can be called recursively. This program just illustrates that point, by calling the operator == function recursively, leading to an infinite loop. .
Question: 

class opOverload{ public: bool operator==(opOverload temp); }; bool opOverload::operator==(opOverload temp){ if(*this == temp ){ cout<<"The both are same objects\n"; return true; } else{ cout<<"The both are different\n"; return false; } } void main(){ opOverload a1, a2; a1= =a2; }

Language: 
Answer: 
Runtime Error: Stack Overflow