Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vector declaration "expected parameter declarator"

Tags:

I have a line of code inside a class's private member variables:

vector<double> dQdt(3)

When compiling in xcode, this gives an error "expected parameter declarator." I think I provided sufficient info. I don't see anything wrong with this declaration.

like image 206
roulette01 Avatar asked Sep 18 '16 16:09

roulette01


1 Answers

You have to initialize the variable in the constructor's initializer list:

class X 
{
    private:
     vector<double> dQdt;
    public:
     X() : dQdt(3) {}
};
like image 92
BitFlip Avatar answered Sep 18 '22 01:09

BitFlip