iDevGames Forums
C++ vectors and typedefs... - Printable Version

+- iDevGames Forums (
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Programming Languages & Scripting (/forum-8.html)
+--- Thread: C++ vectors and typedefs... (/thread-5355.html)

C++ vectors and typedefs... - WhatMeWorry - Jul 1, 2005 09:35 AM

typedef struct WeaponElementEntry
WeaponElement &we;

typedef vector<WeaponElementEntry> VectorOfElementEntries;

The above snippet , which seems pretty straightforward to me, returns
a "expected initializer before '<' token" "VectorOfElementEntries does
not name a type"

What's the matter?


I even simplified the above to just this:

typedef int HeyThere;

typedef vector<HeyThere> VectorOfElementEntries;

Same error?!

Do C++ container have limitations that I'm not aware of, or is
this a stupid syntax problem?


C++ vectors and typedefs... - Fenris - Jul 1, 2005 09:57 AM

Are you sure you included <vector> and 'using namespace std'?

C++ vectors and typedefs... - WhatMeWorry - Jul 1, 2005 11:03 AM

I had the less general form

#included <vector>
using std:vector;

But "using namespace::std" fixed the problem! Needless to say I've globally
replaced all my usings with "namespace std" throughout my project. I won't
be using std::container form ever again.


C++ vectors and typedefs... - OneSadCookie - Jul 1, 2005 04:05 PM

"using std:vector" doesn't mean anything, but "using std::vector" does mean precisely what was intended, and is much better than importing the whole namespace. They're in a namespace for a reason, so you can easily avoid clashes with your own names, even when more things are added to the standard. Don't paint yourself in for the sake of not writing a few "std::"s.

C++ vectors and typedefs... - PowerMacX - Jul 1, 2005 04:39 PM

We really need the code to uDG entries to be made available from within iDevGames - many of these kind of questions could be answered by just browsing around in that code.

For instance:
  • use of namespaces
  • templates
  • header guards
  • loading jpgs/pngs and using them as textures
  • OpenAL/SDL_mixer/Quicktime usage

...and so on.

C++ vectors and typedefs... - ejtttje - Jan 16, 2007 10:09 AM

This may be old news by now, but what you needed was to add a 'typename':

typedef int HeyThere;
typedef [b]typename[/b] vector<HeyThere> VectorOfElementEntries;

You need the 'typename' whenever you are doing a typedef of a templated type.