Click here to Skip to main content
15,891,657 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C++
struct GridProperty 
{
		CString Tag; 
		CString ObjectName; 
		CString ObjectType;	
}

CArray<gridproperty,gridproperty> GridPropertiesArray;


Everything is working fine. This gives an array of structures like this:

GridPropertiesArray[0] -- struct GridProperty
GridPropertiesArray[1] -- struct GridProperty
..
.. etc

Now i want an array of CArray like:

CarrayArray[0] --- GridPropertiesArray -- GridPropertiesArray[0]struct GridProperty
-- GridPropertiesArray[1]struct GridProperty
..
CarrayArray[1] --- GridPropertiesArray -- GridPropertiesArray[0]struct GridProperty
-- GridPropertiesArray[1]struct GridProperty
..
..
.. etc

How to do this?
Posted

1 solution

Assuming your declarations are correct, just reapplying them I'll get
typedef CArray<gridproperty,gridproperty> GridPropertiesArray_t
CArray<GridPropertiesArray_t,GridPropertiesArray_t> GridPropertiesArrays;

Where GridPropertiesArrays is the object you need.

Note: in case you want to avoid typedefs, if your compiler is not fully C++0x compliant (or set up to compile as c++03), pay attention to let a space between two consecutive < and >
 
Share this answer
 
Comments
amarasat 23-Aug-11 10:31am    
typedef CArray<gridproperty,gridproperty> GridPropertiesArray_t
CArray<gridpropertiesarray_t,gridpropertiesarray_t> GridPropertiesArrays;

CArray<gridproperty,gridproperty> DuplicatePropertiesArray; --- this CArray has 10 items in it. (I want to put all these 10 items as another array's first item).

Now the following line gives me an error
GridPropertiesArrays.Add(DuplicatePropertiesArray);

error:: C2664: 'CArray<type,arg_type>::Add' : cannot convert parameter 1 from 'CArray<type,arg_type>' to 'CSFT::cPropGrid::GridPropertiesArray_t'
with
[
TYPE=CSFT::cPropGrid::GridPropertiesArray_t,
ARG_TYPE=CSFT::cPropGrid::GridPropertiesArray_t
]
and
[
TYPE=CSFT::cPropGrid::GridProperty,
ARG_TYPE=CSFT::cPropGrid::GridProperty
]
No copy constructor available for class 'CArray<type,arg_type>' or constructor attempts to perform illegal conversion to non-__gc reference
with
[
TYPE=CSFT::cPropGrid::GridProperty,
ARG_TYPE=CSFT::cPropGrid::GridProperty
]
amarasat 23-Aug-11 12:18pm    
Can anybody help me with error above, i am still not getting how to do this.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900