In c++ 17 when attempting to initialize a member pointer through the scope (not in the member initializer list) of the non-default constructor an error is thrown, as stated below:
error: expression cannot be used as a function
Why is this invalid? I understand from the error that the pointer has been implicitly initialized, hence the constructor cannot be called. I have read the relevant passage from the standard and it's still unclear, as it states that it should have indeed not been initialised yet and therefore my code should be valid.
class Container{
private:
int length;
double* data;
public:
Container(): length(0), data(nullptr) {}
Container(const int length): length(length) {data(nullptr)}
};
int main()
{
Container a(2);
}