Re: How do I use this typedef in a vector?
<AalaarDB@gmail.com> wrote in message...
Basically, how do I do this? If there is no legal way to do what I
want, why not? It seems very logical.
I want the array as a typedef for elegance and so I can do
treasury.front()[0] or treasury[0][0]
typedef int taxTable[8];//the type taxTable should be 8 ints
int size = sizeof(taxTable);//32, shows the array is working ok
taxTable taxes;
std::vector<taxTable> treasury;
treasury.push_back(taxes);
file://error C2440: 'initializing' : cannot convert
file://from 'const int [8]' to 'taxTable '
treasury.resize(1);
file://error C2440: '<function-style-cast>' :
file://cannot convert from 'int' to 'taxTable '
Why not just use 'vector'?:
std::size_t const Size( 7 );
{
int tax[ Size ] = { 15, 19, 3, 54, 12, 53, 25 };
int tax2[ Size ] = { 5, 71, 53, 4, 112, 86, 2 };
int tax3[ Size ] = { 52, 27, 35, 44, 2, 18, 3 };
std::vector<int> TaxArr( tax, tax + Size );
std::vector<int> TaxArr2( tax2, tax2 + Size );
std::vector<std::vector<int> > TaxTables;
TaxTables.push_back( TaxArr );
TaxTables.push_back( TaxArr2 );
TaxTables.push_back( std::vector<int>( tax3, tax3 + Size ) );
for( std::size_t i(0); i < TaxTables.size(); ++i ){
for( std::size_t k(0); k < TaxTables.at(i).size(); ++k ){
std::cout<< TaxTables.at( i ).at( k ) <<" ";
} // for(k)
std::cout<<std::endl;
} // for(i)
}
/* -output-
15 19 3 54 12 53 25
5 71 53 4 112 86 2
52 27 35 44 2 18 3
*/
--
Bob R
POVrookie