CDynamicArray cannot use SGVector as data type, but why don't you store all scope indices and the number of variables at beginning to CDynamicArray< int32_t>? 
Well, if you insist to use SGVector, try SGVector<>*.