Click to See Complete Forum and Search --> : Studying CTypedPtrArray


TraderBoy
August 28th, 1999, 04:35 AM
I have managed to input data into my CMyClass derived class and add it to MyArrayOfPtrs which was created from CTypedPtrArray<CObArray, CMyClass*>. Assume CMyClass has 3 CString member vars, say m1, m2, & m3. Once I know the zero-based subscript of the myclass, should I be able to reference a member with []? Such as MyArrayOfPtrs[34].m1????? Or is this asking too much. Thanks to anyone who might offer a little explanation!

hninyu
August 28th, 1999, 06:24 AM
Ok ,
You can use []. But you can't use like "MyArrayOfPtrs[34].m1?????" because you use CMyClass*. It should be MyArrayOfPtrs[34]->m1. Actually it is the same use of CObArray or CPtrArray but it is type safe. Don't forget to allocate the element before adding the element to the array and to deallocate the element after removing that element from the array.

Hnin Yu