I have the following code:
class A { public: A(const unsigned int val) : value(val) {} unsigned int value; }; int main() { int val
The reason behind the warning is already explained by other answers.
This is how to fix this warning/error. Create a constructor which takes initializer_list as argument.
A(std::initializer_list l) : value(*(l.begin())) { cout << "constructor taking initializer list called\n"; }