I’m trying to create a vector with a specific size, of 255 (max)..
It doesnt work for me, like I see in examples over the internet…
I’m using Microsoft Visual C++ 2012…
I have the current code :
#include <iostream>
#include <string>
#include <vector>
#include <stdlib.h>
using namespace std;
const int MAX = 255;
class test
{
vector <string> Name(MAX);
};
int main()
{
system("PAUSE");
}
It gives me 2 errors :
Error 1 error C2061: syntax error : identifier 'MAX'
2 IntelliSense: variable "MAX" is not a type name
Thanks for your help!
That’s not valid syntax for a class declaration. Try:
You can write
vector <string> Name(MAX);when you create a variable (in your case, you’re declaring a member). For example:would be perfectly valid.