I want to make a vector first without a size ( vector<int> times) and I want to define its size later in a constructor of a class ( times(size) ).
I can do it by using the initializer list as you see below
class A (int size): times(size) {};
But my question is that why I can not do it in a constructor out of a class like the code below?
I mean why the code below is wrong?
class A
{
public:
A(int size);
private:
std::vector<int> line;
};
A::A(int size)
{
line(size);// here I got the error
}
line(size) make an error
Aucun commentaire:
Enregistrer un commentaire