ID:277350
 
Can I use the operator keyword to make a ** operator?
Is it considered bad programming to use a char as a very small integer?
Should I use CLR ?
And in CLR what does the ^ operator do ? (not Xor)
Xx Dark Wizard xX wrote:
Can I use the operator keyword to make a ** operator?

No.


Is it considered bad programming to use a char as a very small integer?

It's not very conceptually "clean", but everyone does it (probably because there isn't any better way). So if you really need a 1-byte integer, go for it. (However, do consider whether you need a 1-byte integer. Often you don't. Saving 1 byte is not worth it.)


Should I use CLR ?

In my opinion, no. At the very least you should learn the standard way first. It's not standard when used when C++. If you want to learn it (not a bad idea - it's worth getting experience with as many languages as possible), then learn a language that's designed for it, like C#.


And in CLR what does the ^ operator do ? (not Xor)

In C++ it's bitwise XOR. I don't know what it is in C#.
Xx Dark Wizard xX wrote:
Can I use the operator keyword to make a ** operator?

You can only use:
+
-
*
/
->
[]
==
=
++
--
new
delete
(You have to look to find the prefix version specifications for those)
<hr>
Thats all I could remember, I probably forgot some.

Also, don't operator overload something that is going to make no sense (like subrtaction using +).
In response to Crispy (#1)
Crispy wrote:
In C++ it's bitwise XOR. I don't know what it is in C#.

In the main() I saw it in there.
int main(array<System::String ^> ^args)
In response to Xx Dark Wizard xX (#3)
I have no idea what that is. Maybe some kind of weird pointer syntax. Go look up a C# site, it should explain it there.
In response to Crispy (#4)
It's not C#. It is CLR C++. C# doesen't allow ypu to use pointers without unsafe in it. And the /unsafe compiler option. It is some string operator.
In response to Xx Dark Wizard xX (#5)
Actually, it is to do with pointers. Not strings. Five minutes with Google could have told you this (which is what I just spent).

http://blogs.msdn.com/branbray/archive/2003/11/17/51016.aspx