Tag Archives: Initialization List

[Solved] Error: error C2601: ‘b‘ : local function definitions are illegal error C2063: ‘b‘ : not a function

Scene:

In general, this problem may be that a "}" is missing
There is also a small probability that your C++standard library is C++98 or earlier, which does not support non built-in initialization list writing.


the Situation of Missing ‘}’

We can see that if our test1 method is short of one}, all subsequent functions will report errors. We need to check it carefully

Solution
Check for yourself that the first line of code near the line number that reports the error is missing a }.

C++ standard does not support
When your C++ standard is C++98, the initialization list of C++98 does not support the initialization list methods of non-built-in types. This can be seen in the following code

#include <iostream>
#include <vector>
#include <map>
using namespace std;

int main()
{
	int a[] = { 1, 2, 3 };

	int b[] {1, 2, 3};
	vector<int> v{1,5,5};
	map<int, float> m{{1, 2.f}, {2, 3.2f}};

	return 0;
}

编译结果:

Solution:
Then in this case your non-built-in type variables will have to be initialized using other methods