Непосредственно подготовлено, но STL замечательный, и вы всегда можете объединить свой путь:
#include <map>
#include <vector>
#include <string>
#include <iostream>
typedef std::map<std::string, int> col_val_map;
typedef std::vector<col_val_map> table;
int main(){
table t(3);
std::string col = "Width";
t[0][col] = 5;
t[1][col] = 3;
t[2][col] = 10;
col = "Height";
t[0][col] = 10;
t[1][col] = 20;
t[2][col] = 2;
col = "Random";
t[0][col] = 42;
t[1][col] = 1337;
t[2][col] = 0;
std::cout << "\t\tWidth\t\tHeigth\t\tRandom\n";
for(int i=1; i <= 3; ++i){
std::cout << i << "\t\t" << t[i-1]["Width"]
<< "\t\t" << t[i-1]["Height"]
<< "\t\t" << t[i-1]["Random"]
<< "\n";
}
}
С выводом, показанным на Ideone .
Или, как говорит @DeadMG, наоборот:
#include <map>
#include <vector>
#include <string>
#include <iostream>
typedef std::vector<int> row_val_array;
typedef std::map<std::string,row_val_array> table;
int main(){
table t;
t["Width"].reserve(3);
t["Width"][0] = 5;
t["Width"][1] = 3;
t["Width"][2] = 10;
t["Height"].reserve(3);
t["Height"][0] = 10;
t["Height"][1] = 20;
t["Height"][2] = 2;
t["Random"].reserve(3);
t["Random"][0] = 42;
t["Random"][1] = 1337;
t["Random"][2] = 0;
std::cout << "\t\tWidth\t\tHeigth\t\tRandom\n";
for(int i=1; i <= 3; ++i){
std::cout << i << "\t\t" << t["Width"][i-1]
<< "\t\t" << t["Height"][i-1]
<< "\t\t" << t["Random"][i-1]
<< "\n";
}
}
Опять же, показано на Ideone .