I just got a C++/CLI book a couple days ago, and so far there are a few things that confuse me (the first four aren't really important, just confusing MS decisions).
1. First of all, why is there both an enum struct and an enum class if they're both the same.
2. Why did MS remove default arguments for ref classes?
3. Why do ref classes not support friends?
4. Why is there no private or protected inheritance for ref classes? (Not such a big deal as, in my experience, it is rarely used; but still...)
5. My book says value classes are created directly on the stack, but what if you did something like this:
This compiles, but is it created on the managed heap? The book only says, "...when a new instance of the data type is created, it is allocated either to the stack or CRT heap."Code:
value class Foo
Foo^ bar = gcnew Foo;
6. What is the difference between the two different ways of operator overloading in C++/CLI? There is the traditional (or close to) ISO C++ way, as well as static operators; e.g.,
If I use the latter version, it only works with handles (^) and if I define both, then only the former is called. :confused:Code:
//(almost) ISO C++
Foo% operator++(int) //also works with Foo& return, but only for value types
//C++/CLI new syntax
static Foo^ operator++(const Foo^ lhs)
I could go on with some complaints and design rationale questions, but I'll leave it at that for now ;)