- Home /
The question is answered, right answer was accepted
Is it possible to change the definition of '~' from that of a destructor/finalizer and into that of an underscore '_' ?
Hey all. Just kind of a silly question here. I want to use ~ to demarcate my variables, nothing super important, but I did some reading and saw that it's used as a finalizer/deconstructor for garbage collection. It sounds like something I would most likely never use, so I was wondering if it was possible to override the definition of the tilde symbol and change it to be the equivalent of an underscore, so I can put it in front of variables. Is this impossible, or a very bad idea?
Thanks to anyone who can help, or just telling me what a stupid idea it is, haha
Answer by DiegoSLTS · Apr 22, 2019 at 03:02 AM
That's no possible, you can't replace symbols. I don't know if it's a "bad" idea, but it is really weird trying to modify basic syntax of a language.
Right, in addition to the destructor it's also the unary bitwise not / complement operator. So no, it's definitely not possible. I just wonder for what kind of "demarcating" one would use the ~ character ins$$anonymous$$d of _. They actually look quite similar and can easily be mistaken. So it would counteract the actual goal. What kind of variables do you want to demarcate ? Just give them meaningful names. The only things you may want to distinguish are private vs public variables. I generally use the "old" m_VarName
style for private member variables. $$anonymous$$ethod arguments I almost always prefix with an "a" (for argument).