Doug,
If I have have declared a pointer to CString[2]. How to create object of
CString[2] (syntax):
For example:
CString (*llv)[2] = new CString[2]; //Here fail right side
The expression:
new CString[2]
creates an array of two CStrings and returns a pointer to its first
element; this pointer has type CString*, as is the case for any array
CString[n]. So if your RHS is correct, you need:
CString* llv = new CString[2]; // Fine
On the other hand, if your LHS is correct, you're talking about a pointer
to an array of two CStrings, which is different, because the thing pointed
to is a CString[2], not a CString. Pointers to arrays come into play when
dealing with 2D arrays. For example:
CString (*llv)[2] = new CString[2][2]; // Fine
CString (*llv)[2] = new CString[3][2]; // Fine
CString (*llv)[2] = new CString[4][2]; // Fine
Here, new[] returns a pointer to the first element of an array
CString[m][2]. This element has the type CString[2], and so a pointer to it
has the type CString (*)[2].
In plain English, what type are you trying to create?