Is it possible to have the class (the instance of a class) return a value? I mean like this:
So that when I simply type the name of the instance, a certain data from the class is returned (in this case the Var).Code:class MyOwnInt
{
public:
int Var;
char Letter;
};
int main()
{
MyOwnInt MyVar;
int TempVar = MyVar; <-- Here
return 0;
}
I believe you can overload the [ ] operators to return values (like an array), but that's not quite what I want. No extra operators. Just the class name.