Help with initializing a vector
CPattern is just a plane generic class
in my other class i define the vector like so
vector m_Patterns;
I get this error
error C2143: syntax error : missing '';'' before ''<''
error C2501: ''CPatternController::vector'' : missing storage-class or type specifiers
error C2238: unexpected token(s) preceding '';''
it doesn seem to recognize and i havent done a vector in 6 months
i would think it would be vector m_Patterns;
please help I need the correct initialization.
thanks,
nick
These errors are a bit difficult to debug without the code in front of us to tweak with, but it sounds as though it doesn''t know what a vector is. You did make sure to include
<vector>
, right?
i used #include <vector>
I searched for vector.h and it doesn''t exist on my computer, can I get it somewhere
the code I gave is the only code in the file other than the contructor and destructor which have nothing in them
I searched for vector.h and it doesn''t exist on my computer, can I get it somewhere
the code I gave is the only code in the file other than the contructor and destructor which have nothing in them
well, i think u need to specify the data type that the vector is gonna store. the STL uses templates. so ur code shud be:
[edited by - crazee on May 8, 2003 12:17:07 PM]
vector<datatype> m_Patterns;
[edited by - crazee on May 8, 2003 12:17:07 PM]
To initialize a vector you need to specify the data type also, i.e. u need to tell the compiler what kind of data the vector will store.
For e.g.
In the above example a vector NumVector of type "int" will be created.
in the same way you must give...
"There is a Bug in every Code!"
For e.g.
#include <vector> . . . vector <int> NumVector; . . .
In the above example a vector NumVector of type "int" will be created.
in the same way you must give...
vector m_Patterns;
"There is a Bug in every Code!"
There was a error in my previous post.
this is the corrected one...
To initialize a vector you need to specify the data type also, i.e. u need to tell the compiler what kind of data the vector will store.
For e.g.
In the above example a vector NumVector of type "int" will be created.
in the same way you must give...
"There is a Bug in every Code!"
this is the corrected one...
To initialize a vector you need to specify the data type also, i.e. u need to tell the compiler what kind of data the vector will store.
For e.g.
#include <vector> . . . vector <int> NumVector; . . .
In the above example a vector NumVector of type "int" will be created.
in the same way you must give...
vector <your_data_type> m_Patterns;
"There is a Bug in every Code!"
You can use < and > to create the less than and greater than symbols respectively.
The first way you declare the vector is incorrect, unless you are passing your own allocator. here for details.
The problem is that the
At the top of the module, either:
or
Or you can simply prefix std:: wherever you use a vector:
The first way you declare the vector is incorrect, unless you are passing your own allocator. here for details.
The problem is that the
vector
class is under the std
namespace in the standard headers. To use it, you can do one of three things:At the top of the module, either:
using namespace std;
or
using std::vector;
Or you can simply prefix std:: wherever you use a vector:
std::vector <CPattern> m_Patterns;
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement