Implement conversion operator for pointer

Viewed 2855

The question is simple but i can't find a solution.

class foo
{
public:
    operator int()
    {
        return 5;
    }
};

foo* a = new foo();   
int b = a;

Is it possible to implement that behavior?

2 Answers
Related