Re: vectors
Clark Cox <[email protected]>
| Newsgroups | gmane.comp.macosx.devel |
|---|---|
| Message-ID | <[email protected]> |
On Sat, Dec 5, 2009 at 9:59 AM, ML <[email protected]> wrote: > Hi Clark, > > Thanks for the reply. > >>> I have code that uses a standard vector. > >>> I get errors that say: ISO forbids declarations of vector with no type. > >> That's probably because CW8 did the (non-standard/pre-standard) trick >> of putting everything in the global namespace. vector is in the std >> namespace and as such you'll need to do one of the following: >> >> 1) Add "using namespace std;" to your file in order to bring in the >> whole std namespace >> 2) Add "using std::vector" in order to just bring in vector >> 3) Use the fully qualified "std::vector" wherever you currently use "vector" >> >> Personally, #2 is the option that I usually go for (i.e. just pull in >> the symbols that I use). > > > > OK, so I like #2 better, what if I was using vector and list? > > Can I do something like: "using std::vector::list" They would each need to be separate lines: using std::vector; using std::list; > Or can I just do this when I actually declare and use the vector each time: > "using std::vector <type> vector_name" If I understand you, you would do: typedef std::vector<type> vector_name; which would make "vector_name" a synonym for std::vector<type> -- Clark S. Cox III [email protected]