Improve company productivity with a Business Account.Sign Up

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 282
  • Last Modified:

does anyone know why this is happening:

i have a class that includes vector.h as a header file but when i have a vector declaration like this:

vector<_variant_t, _variant_t> m_myVariable it gives this error:

error C2143: syntax error : missing ';' before '<'

i tried commenting everything out of the file except for the include and the line

vector a;

same error

i tried commenting everything out except the line

vector<int> a;

same error.

what is going on with this thing?
1 Solution
Your include statement needs to look like this:
#include <vector>

Then you can either put this after it:
using namespace std;

or, declare like this:
std::vector<_variant_t, _variant_t> m_myVariable;

>>what is going on with this thing?

>>i have a class that includes vector.h

You'll have to

#include <vector> // NOTE: No .h extension

using namespace std; // use the standatd namespace
To make a long story very short, vector.h is not a part of standard c++.  The standard includes do not have the ".h".
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

emily_hallAuthor Commented:
ok thanks - but now i am getting this as an error:

c:\program files\microsoft visual studio\vc98\include\vector(24) : error C2039: 'size_type' : is not a member of 'CRecord'

that is with my declaration like this:

vector<_variant_t> m_myVariable

the size_type is something that is declared as being part of vector...

To make a long story very short, vector.h is not a part of standard c++.  so the include should look like that:
#include "vector.h"

now, for the constructor:
  you shold look at the vector.h file and see
  what kind of constructor it have.
  if it's the regular constructor, the declaration should
  look like that:
  vector myVector(a,b);

  and if you will write:
  vector<_variant_t, _variant_t>
  what is that "<" ?
  the Compiler will think that it should be
  "vector;" and the "<_variant_t, _variant_t>" it's a
  Yes, it should be #include <vector> (NO .h!)

  And vector is a template.  The "< >" is how your parameterize a template when you instantiate it.
  Are you sure your declaration is not
  vector<_variant_t, _variant_t> m_myVariable;

  It looks for the member size_type on the second parameter you in the list.  If you only pass one parameter, such as in
  vector<_variant_t> m_myVariable;
then the second parameter defaults to allocator<T>, where T is the first parameter you pass.  This *should* work.

Also, make sure that you are not somewhere in the include chain including <vector.h>.  It you are or are not, it would not hurt to do this
  std::vector<_variant_t> m_myVariable;

emily_hallAuthor Commented:
woohoo!  it works!  thanks!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now