mardi 28 avril 2015

Template class without default constructor

I guess this has been asked before but I could not find a thread for it

Lets say that we have the class A:

Class A
{
    public:
       A() = delete;
       A( const int & y )
       : x( y )
       {}
    private:
       int x;
};

How can I create a vector of type A and give an argument to A's constructor?

Edit: I tried with std::vector<A(3)> myvector; but it did not compile...

Aucun commentaire:

Enregistrer un commentaire