mardi 25 août 2015

Inheritance of operators in c++

I have read many similar questions on this site, but nothing that answers what I am trying to do.

public class base {
public:
    base(){
        //Default Constructor
    }

    base( int num ){
        // use num to create base
    }

    base& operator=( base&& _data ){
        // do move assignment stuff
    }
};

public class derived : public base {
public:
    derived() : base() {
        int num1;
        //Do some stuff

        // Now I want to assign the base of this class with a new base
        base::operator=( Base( num1 ) );
    }
};

I would like to call the move assignment ( or just regular assignment ) on the base class during the derived class's construction. This way that the derived class can parse some information before it creates its base. This just doesn't seem to work. Anyone have any ideas?

Aucun commentaire:

Enregistrer un commentaire