I have edited this question to make myself clear. My question was.
If we define
String a
we can define characters as a[],
but if we define String ^ a
a[] cant be defined.
So why a[] is not defined if both are strings.
I have edited this question to make myself clear. My question was.
If we define
String a
we can define characters as a[],
but if we define String ^ a
a[] cant be defined.
So why a[] is not defined if both are strings.
String^ is a handle to underlying string. These are much like pointers/references in C++ except the aid they provide to garbage collector. That means you don't need to delete memory for them as you do for pointers in C++.
Microsoft's Managed C++ is radically different from the standard definitions you are used to in usual C++. One major difference is the way it handles memory allocation/freeing using managed pointers. The ^
you are referring to is called the hat operator and it is used to denote a pointer whose memory state is managed automatically at run-time. This means you will not have to use delete
to free memory previously allocated for it.
While the usefulness/efficiency of the hat operator is disputed, it remains the standard way to manage memory in your case of Visual C++ .NET.