I have an exercise in a book I'm reading that wants me to 'typedef' a pointer to an array of char, which is what I'm really getting at. This leads me to believe it can be done in one line without using 'new' because the book has not introduced 'new' yet (though I know what it does).
A typedef isn't actually creating any variables. It just defines another way to refer to a type.
typedefchar SomeType;
Now you can use SomeType just like you would the type char. It does not actually create any char's or anything; it just let's you use that name instead.
Note: pointers to different sized arrays are considered different types.
1 2 3 4 5 6
int array1[4];
int array2[6];
int (*ptrIntArray1)[4] = &array1;
int (*ptrIntArray2)[6] = ptrIntArray1; //Error cannot convert from 'int (*)[4]' to 'int (*)[6]' Need a cast
Right. I understand typedef'ing and I understand pointers to arrays. What I don't understand is how to combine the two so that I can typedef a pointer to an array of <type>.