Solved

does anyone know why this is happening:

Posted on 2001-08-02
8
232 Views
Last Modified: 2011-10-03
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?
0
Comment
Question by:emily_hall
8 Comments
 
LVL 2

Expert Comment

by:Lockias
ID: 6345921
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;

~Lockias
0
 
LVL 86

Expert Comment

by:jkr
ID: 6345923
>>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
0
 
LVL 2

Expert Comment

by:Lockias
ID: 6345928
To make a long story very short, vector.h is not a part of standard c++.  The standard includes do not have the ".h".
0
 
LVL 1

Author Comment

by:emily_hall
ID: 6346078
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...


0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Expert Comment

by:CTrip
ID: 6346574
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
   mistake
0
 
LVL 2

Expert Comment

by:Lockias
ID: 6346601
CTrip:
  Yes, it should be #include <vector> (NO .h!)

  And vector is a template.  The "< >" is how your parameterize a template when you instantiate it.
0
 
LVL 2

Accepted Solution

by:
Lockias earned 100 total points
ID: 6346620
emily,
  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;

~Lockias
0
 
LVL 1

Author Comment

by:emily_hall
ID: 6346652
woohoo!  it works!  thanks!
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now