I have a class with a single int member such as:
class NewInt {
int data;
public:
NewInt(int val=0) { //constructor
data = val;
}
int operator int(NewInt toCast) { //This is my faulty definition
return toCast.data;
}
};
So when I call the int()
cast operator I'd return data
such as:
int main() {
NewInt A(10);
cout << int(A);
}
I'd get 10 printed out.