vendredi 1 février 2019

Initialize a class with an array

I have a class like this:

class MyClass {
    MyClass(double *v, int size_of_v){
        /*do something with v*/
    };
};

My question: Is there any way, I can initialize such class without defining an array of double and feeding it to the constructor?

I would like to do something like:

auto x = MyClass({1.,2.,3.}, 3);

Aucun commentaire:

Enregistrer un commentaire