vendredi 22 juillet 2016

C++ Make sure contructor gets called only once

I have the following class definition:

Class Test
{
    private:
        List<Test> test;
};

When I try to create an instance of it I get a segmentation fault and I know it's because Test's constructor gets called recursively until the error happens, but I have no idea how to fix it. I've written my own template class List it can be found here.

When I use the standard vector this does not happen.

How do you generally work around such problems?

Aucun commentaire:

Enregistrer un commentaire