Hello! I don't know if this is the correct forum, sorry, i am new here..
Well... i am using this method of array declaration:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
char* aFieldMain[]{
"name",
"id",
"password",
"control",
"sysmodel"
};
char* aFieldSub[]{
"tel",
"id",
"address"
};
char* aFieldExtra[]{
"fav",
"access",
"model",
"option",
"controlsys",
"method",
"controlvar",
"limitation",
"register"
};
|
1)Well... there isn't a way that i can put all these arrays in one array in cpp?
for example, in PHP we would do like that:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
<?php
$mainarray=array(
array("name","id","password","control","sysmodel"),
array("tel","idz","address"),
array("fav","access","model","option","controlsys","method","controlvar","limitation","register")
);
//and by showing the value content like this:
printf($mainarray[1][2]);
echo "\n<br>\n";//jump a html line, or the output will be in one line
//output:"idz"
printf($mainarray[0][4]);
echo "\n<br>\n";
//output:"sysmodel"
printf($mainarray[2][8]);
echo "\n<br>\n";
//output:"register"
?>
|
by the way... remember that we may not know the number of elements in each array.
And too, i already visited this section :
http://www.cplusplus.com/doc/tutorial/arrays.html#multidimensional_arrays
but they have defined arrays. i don't want to declare the number of elements in each array.
that ends my question.
So.... the following ones are just a curiosity, i know they hardly will work in cpp.
2)in php, we can do that:
1 2 3 4
|
$array1=array(
array("test1","test2"),
"abcd" => array(1,2)
);
|
This is possible in cpp?
We can go furthermore:
3)
1 2 3 4 5
|
$array1=array(
2000 => array("test1","test2"),
"abcd" => array(array("a1",1),array("2",true))
);
|
I really don't think that is possible. by the way...... on examples 2 and 3, please forget the
vartype on cpp. just think that they are all char.
Thank you for your patience.