Variables can only be constructed at the point of instantiation.
This instantiates a variable named v and runs its constructor:
|
std::vector<char> v( 5, 'X' ); // v is now { 'X', 'X', 'X', 'X', 'X' }
|
In your code, "terrain" was already instantiated elsewhere. Consequently,
the compiler was thinking that you wanted to call std::vector<...>::operator()
with the parameters Main::MAP_HEIGHT and std::vector<char>(Main::MAP_WIDTH, 'T').
But std::vector<> does not provide the function call operator.
I'm not sure where exactly you put that line of code -- be it in a class constructor or
elsewhere. For example, it is a common beginner (not saying you are one--I don't
know) error to do something like this:
1 2 3 4 5 6 7 8 9 10
|
class MyClass {
std::vector<char> v;
public:
MyClass();
};
MyClass::MyClass()
{
v( 5, 'X' ); // Wrong
}
|
The right way would be to put that line of code in an initializer list:
1 2 3 4
|
MyClass::MyClass() :
v( 5, 'X' ) // Right!
{
}
|
Or, a bad, but workable solution would be:
1 2 3 4
|
MyClass::MyClass()
{
v = std::vector<char>( 5, 'X' ); // OK, but the previous solution is preferred
}
|