quote:Original post by amemorex
by overloading the int operator, i will have to re-set whatever variable i want to equal the class''s value, each time it changes, which is a pain in the ass..meaning
You''d have to do that for a standard type too. If your intention is making a user type that''s just like an int, this is consistent behavior:
int a = 4;
int b = a; // b = 4;
a = 2; // b still = 4
quote:
i''d have to do that every time nr changes, which would be a major pain in the butt, when i would like to just use "nr" by itself whenever needed, y''know?
Then what you''re talking about is a reference. I have no idea how to overload for references, it''s something that maybe you should try. I''m sure this would work:
MyType blah;
MyType &ref = blah; // from now on, ref acts just like blah & vice versa
But I''m pretty sure this wouldn''t:
int &ref = blah; // where blah is still a MyType
quote:
but im under the impression that this isnt possible, heh
i really wish i knew how the STL programmers went about this (stl string variables, for instance)
Lucky for you STL has almost no object code; everything''s inlined in the headers. Just open the header files and start digging. Sure, the variable names might be scary, but that shouldn''t scare bad-ass coders like ourselves.
quote:
or then again, is it possible in any way to maybe "overload" a normal variable with a class''s functions? im seriously doubting it, but..
No idea what you''re saying here. By variable do you mean "built-in type"?, as in class MyClass : public int? If you do, the answer is no.