C 的STL中的map的問題。map的巢狀定義可不可以多級巢狀還是說只能二級map

2021-04-20 20:03:53 字數 1535 閱讀 5155

1樓:匿名使用者

只要二級行,多級肯定沒問題, 不過級數太多操作太麻煩,何必這麼折騰

2樓:程式設計大亨

#define _crt_secure_no_warnings#include

#include

#include

using namespace std;

int main()

三層以上是會報錯

源,超出修飾

bai名的長du度,名稱zhi被截斷,說白一點就是c++不支援dao太長的型別修飾

c++中stl類别範本的問題,我想把物件直接放入一個map中遍歷,問下大神該怎麼改 30

3樓:小樓之外

for (it = n.begin();it != n.end();it++)

輸出來的是it.first,在

自上面it = n.begin();,能夠賦值成功嗎?

4樓:匿名使用者

//**如下,你自己對比看看

#include

#include

#include

using namespace std;

class cardriver

const char* getname() constprivate:

string m_name;

};class truckdriver

const char* getname() constprivate:

string m_name;

};class busdriver

const char* getname() constprivate:

string m_name;

};template

class vehicle

void show()

private:

t m_driver;

string m_type;

int m_cout;

int m_speed;

int m_weight;

};int main(int argc, char* argv)vehiclebus1("chen","bus",30,50,1000);

typedef map< int,vehicle> vb;

vb n;

n.insert(vb::value_type(104,bus1));

vb::iterator it;

for (it = n.begin();it != n.end();it++)

return 0;}

c++ stl中map的問題

5樓:裸跳的螞蚱

你犯了一個錯誤,就是map的[ ]是過載的。比如你寫的map[1],當呼叫這個函式時,它會檢查map中是否有key為1的pair。如果沒有就新增。

所以你使用map[1]這種形式總會有值輸出。另外map使用的並不是陣列,而是紅黑樹。

C程式中與map有關的問題,C新手問題關於map的使用

來自stl map.h 23.3.1.2 element access brief subscript c access to map data.param k the key for which data should be retrieved.return a reference to the ...

夢幻西遊中的STL,夢幻西遊中STL如何加點最牛逼?

變身5件套 腰帶鞋子黑寶石 頭盔瑪瑙 衣服項鍊舍利子 在加把600傷害的 89 stl最好是配血裝備吧 因為魔族本來防就不高 但也不是說放棄防禦 只是說魔族比較擅長的方面給他發揮到最好 呵呵 門派特色 必中的3封,持續當前回合和下回合,不能被五龍解除 可用技能 鷹6 連6 象形 魔息術 現行加點 1...

c中的問題

1 a new a 不一定是例項化。也可能是負值。比如obj a new a 其實大里是三步。obj a new a a new a 我這麼認為。我也沒看資料。2 要看這個class c 是不是最外一級。在外接class前面加private,protected根本不會通過編譯。預設是internal...