Array of Array

 

Is it possible to create an array that contains other arrays of different types? For example, an array that contains matrices of double type and others of type float or int?

The idea is to be able to manipulate (add, remove, sort, etc.) columns of data of different types in an array. It would be a dynamic array of two dimensions, but may contain different types of data. I could do this manipulation using structures, but I thought about creating a class for this.  
Has anyone tried something similar or would have had something in the community that I did not see?

For example:

index string data double date int date char data float date
1




2




3




4




 
Samuel Manoel De Souza:

Is it possible to create an array that contains other arrays of different types? For example, an array that contains matrices of double type and others of type float or int?

The idea is to be able to manipulate (add, remove, sort, etc.) columns of data of different types in an array. It would be a dynamic array of two dimensions, but may contain different types of data. I could do this manipulation using structures, but I thought about creating a class for this.  
Has anyone tried something similar or would have had something in the community that I did not see?

For example:

index string data double date int date char data float date
1




2




3




4




What you've demonstrated here is a single dimensional array of objects. To do what you want to do you would need to derive a class from CObject that has all the fields you need for the different data types and then override the compare virtual method for sorting of objects by a corresponding field. You can use CArrayObj to add dynamic instances of your objects for storage/manipulation. 
 
aslkdjf :
What you've demonstrated here is a single dimensional array of objects. To do what you want to do you would need to derive a class from CObject that has all the fields you need for the different data types and then override the compare virtual method for sorting of objects by a corresponding field. You can use CArrayObj to add dynamic instances of your objects for storage/manipulation. 

I was going down this road. I was just in doubt if that was the way to do it. It confused me to think that I was working with two dimensions. Thanks for clarifying.

Reason: