Ok, I’m coming from vb.net to c++. Im trying to use vectors in a structure, but the compiler yells at at me for it. What is wrong with the current statement?
#include <vector>
struct FactorSet
{
vector<long long> UpperFactor(0);
vector<long long> LowerFactor(0);
};
Output error (Visual Studio 2008):
Error 1 error C2059: syntax error : ‘constant’
I venture to guess it is my lack of understanding of what a vector really is. In my mind it is an object, although I think its whats called a template. Other objects like strings seem to have no problem. I also assume this is extended to class definitions as well since structures and classes are so similar.
You want:
though you might also have problems with long long, as this is not currently part of C++.
If you actually want to give a size to the vectors, you need to do that via the structs constructor:
So now when you say:
the vectors in f will both have size 42.
As to what a vector actually is, it’s a class very like a string, except in the case of the vector you have to say what type of thing it contains. So
is very similar (but not identical) to: