Help us understand the problem. What is going on with this article?

コンテナクラスの初期化

More than 5 years have passed since last update.

C++11から、コンテナクラスの初期化ができる

map好きな自分用メモ(mapにmapを入れた場合の書き方)

a.cpp

#include <stdio.h>

#include <string>
#include <map>

int main( int , char ** ) {

    std::map< std::string, std::map< std::string, std::string > > data = 
    { 
        { "key1", 
            { 
                { "key1_1", "a" }, 
                { "key1_2", "b" }, 
            } 
        }, 
        { "key2", 
            { 
                { "key2_1", "c" }, 
                { "key2_2", "d" }, 
            } 
        }, 
    };

    for( auto &i: data ) {

        printf( "%s\n", i.first.c_str() );

        for( auto &o: i.second ) {

            printf( "\t%s=%s\n", o.first.c_str(), o.second.c_str() );

        }

    }

    return( 0 );

}


[todanano@localhost tmp]$ ./a.out
key1
        key1_1=a
        key1_2=b
key2
        key2_1=c
        key2_2=d
[todanano@localhost tmp]$
todanano
C、C++、postgresql、php、perl、sh、その他Linux関連をあれこれ触っています。
http://www.example.com/%E6%8C%81%E3%81%A3%E3%81%A6%E3%81%84%E3%81%BE%E3%81%9B%E3%82%93%E3%80%82
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away