initializing a static vector

I have a static vector data member in my class and Im having trouble to initialize it. My vector's data type is another one of my classes which is called Leg. I've tried the ways I used with an int that worked. So not sure what is different about a vector.

Thanks for any help in advance.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26

#include <vector>
using std::vector;


#ifndef ShortestRoute_h
#define ShortestRoute_h

// ShortestRoute class definition
class ShortestRoute
{
  public:
    static vector<Leg> legVector;   
    ShortestRoute();

  private: 

};

// ShortestRoute constructor
ShortestRoute::ShortestRoute()
{
} // close constructor


#endif 


I've tried in main(), global & in constructor
1
2
3
4
5
6
ShortestRoute sR;
sR.legVector.push_back( Leg1 );
ShortestRoute::legVector.push_back( Leg1 );
vector<Leg> ShortestRoute::legVector.push_back( Leg1 );
ShortestRoute::legVector = aVector;


Last edited on
Topic archived. No new replies allowed.