|
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