Boost logo

Boost Users :

Subject: Re: [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 18:01:25

Thanks much. ________________________________ From: Philipp Moeller <philipp.moeller_at_[hidden]> To: boost-users_at_[hidden] Sent: Friday, March 9, 2012 2:47 PM Subject: Re: [Boost-users] [vector, PropertyGraph] Problem declaring a class member of the "vector<int>" type Alex Sadovsky <a_sadovsky_at_[hidden]> writes: > 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; >>} >>////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// You seem to missing an   #include <vector> and vector should be qualified as std::vector<double>. Also, I'd consider   typedef char* string; to be moderately evil given that there is a type std::string. HTH, Philipp Moeller _______________________________________________ Boost-users mailing list Boost-users_at_[hidden]

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at