I'm wondering if and how to make a class return an integer without calling a member function.
Example
Example A can be done with operator overloading. But what about B and C?Code:int bar (int a); int main() { Foo f(); // create a Foo object // Example A int a; a = f + 1; // Treat f as an int // Example B a = bar(f); // Treat f as an int // Example C return f; // Treat f as an int }
I want to do this so I can make a class, FifoPtr, that behaves exactly like an int except when assigning a new value to it, it does a (% size) before assigning. I'd like to do it without having to call Foo::get_val() or something in examples B and C.
Any ideas?