Boost logo

Boost Users :

Subject: [Boost-users] [vector, PropertyGraph] Problem declaring a class member of the "vector<int>" type
From: Alex Sadovsky (a_sadovsky_at_[hidden])
Date: 2012-03-09 14:03:11


Hello everyone, > >I am trying to declare, in a header file, a class that has a member of type "vector<double>" (the code is included below).  The compiler complains that I haven't included the appropriate namespace (the error message reads, "ISO C++ forbids declaration of ‘vector’ with no type"), and I understand that it is looking for this: > >using namespace boost::numeric::ublas; > >However, I tried putting it in the header file in various places (haven't programmed in C++ in 10 years and couldn't find any online documentation to clarify this specific situation), and still no luck.  I am definitely doing something wrong, but cannot reason out the error, as it probably has to do with the specific syntax conventions.  Any help is appreciated! > >Thanks, >-Al > >P.S.  Code in header file: > >////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// >//  File "airspace-graph-rectilinear-edges.h" >typedef char* string; >const int PHYSICAL_SPACE_DIMENSION = 2; >//  Information needed about a waypoint used in an airspace: name and physical position >class WaypointConcept{ > private: >  using namespace boost::numeric::ublas; >  string waypoint_name; >  vector<double> waypoint_position_xyh(PHYSICAL_SPACE_DIMENSION); > public: >  string GetWaypointName(); >  vector<double> GetWaypointPosition(); >} > >class AirspaceGraphConcept PropertyGraphConcept<class Graph, class WaypointConcept, class vertex_index_t>; >typedef Vertex* GraphPathType;   >typedef string FlightIDType; >typedef boost::unordered_map<std::FlightIDType, GraphPathType> FlightIDToPathAssignmentType; >////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// > >Code in the .cpp file (which includes the above header file) I am trying to compile: >////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// >#include <boost/lambda/lambda.hpp> >#include <iostream> >#include <iterator> >#include <algorithm> >#include <boost/numeric/ublas/io.hpp> >#include <boost/numeric/ublas/vector.hpp> >#include "airspace-graph-rectilinear-edges.h" > >int main() >{ >    using namespace boost::numeric::ublas; > >    vector<double> v(3); >    for (unsigned i = 0; i < v.size(); ++ i) >      v (i) = 2.01*double(i); >     >    std::cout << v << std::endl; >} >////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// > > > > > > > > > > > >  >  >   > >



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net