簡體   English   中英

C ++的結構矢量圖?

[英]C++ Map of Vector of Structs?

所以這是我的代碼片段:


    struct dv_nexthop_cost_pair
    {
      unsigned short nexthop;
      unsigned int cost;
    };

map<unsigned short, vector<struct dv_nexthop_cost_pair> > dv;

我收到以下編譯器錯誤:

error: ISO C++ forbids declaration of `map' with no type

宣布這個的正確方法是什么?

要么你忘了#include正確的標題,要么沒有導入std名稱空間。 我建議如下:

#include <map>
#include <vector>

std::map<unsigned short, std::vector<struct dv_nexthop_cost_pair> > dv;

使用typedef

typedef std::map<unsigned short, std::vector<struct dv_nexthop_cost_pair> > dvnexthopemap;
dvnexthopemap db;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM