2010-04-17 9 views
5

तो यहां मेरे कोड का एक स्निपेट है:सी ++ स्ट्रक्चर के वेक्टर का मानचित्र?

 
    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 

यह घोषित करने का सही तरीका क्या है?

उत्तर

8

या तो आप # दाएं शीर्षकों को शामिल करना भूल गए हैं या std नामस्थान आयात नहीं किया है। मेरा सुझाव है निम्नलिखित:

#include <map> 
#include <vector> 

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

हाँ ... मैं भी शामिल भूल गया। क्षमा करें, सी ++ newb यहाँ। धन्यवाद! – garsh0p

0

उपयोग typedef

typedef std::map<unsigned short, std::vector<struct dv_nexthop_cost_pair> > dvnexthopemap; 
dvnexthopemap db; 
संबंधित मुद्दे