meteoritepanama
meteoritepanama

Reputation: 6252

C++ Map of Vector of Structs?

So here's a snippet of my code:


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

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

I'm getting the following compiler error:

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

What's the proper way to declare this?

Upvotes: 5

Views: 1840

Answers (2)

Mayank
Mayank

Reputation: 1

use typedef

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

Upvotes: 0

Marcelo Cantos
Marcelo Cantos

Reputation: 186078

Either you forgot to #include the right headers or didn't import the std namespace. I suggest the following:

#include <map>
#include <vector>

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

Upvotes: 8

Related Questions