The following code generates an error when the
//vector<int> myVofInt2(n);
line is uncommented. I get: error C2059: syntax error :'constant'.
Does anyone know why it treats the declaration/initializations differently when the vector is inside a class?
The vector<int> in the main function creates a vector<int> with ten elements, which is what I want to do, but I need the object initialized inside a class. I've tried putting the initialization in the class constructor, but that has not worked either.
class myplayclass
{
public:
int x;
int y;
vector<int> myVofInt2(10);
myplayclass(){}
~myplayclass(){}
myplayclass(int intX):x(intX){y=0;}
};
int _tmain(int argc, _TCHAR* argv[])
{
vector<int> myVofInt(10);
return 0;
}