How do I need to define a constructor such that i can construct a class A like A({a,b,c}). This arised in an urge to avoid using a variadic constructor which seems dangerous.
Code:
#include <vector>
class A{
public:
A(const unsigned int a, const unsigned int b, const unsigned int c) /*: A({a,b,c})*/ {}
A(const std::vector<unsigned int> v) {}
};
int main(){
A(1,2,3); //works
A({1,2,3}); // doesnt compile
return 0;
}
My aim is to construct a network with arbitrarily many hidden layers. The vector is supposed to contain the amount of nodes contained by the corresponding layer.
edit:
/home/simbla/qt_projects/minimalWorkingExample/main.cpp:158: error: call of overloaded 'A(<brace-enclosed initializer list>)' is ambiguous
A({1,2,3});
^
Solution:
use std::initializer_list instead of std::vector