Suppose I have a struct:
struct A
{
int i;
};
I can init it as:
A a{1};
Now I have a derived class:
struct B : public A
{
B(int _i) : A{_i} {};
};
But I have a compilation error in B struct ctor:
error: no matching function for call to ‘A(<brace-enclosed initializer list>)’
Compiler is gcc-4.6 (SUSE Linux) 4.6.3
There is nothing wrong with your code; it is simply that your compiler doesn't support all of the required C++11 features.
Your constructor compiles fine with gcc 4.7.0.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.