[SOLVED] Can objects be used as built-ins?
I'm wondering if and how to make a class return an integer without calling a member function.
Example
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
}
Example A can be done with operator overloading. But what about B and C?
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?