mercredi 11 octobre 2017

In-class initialization of data members. Will the value left after the inheritance?

So simple question is, if I have such situation:

    class FooA{
    public:
        int getID(){
            return ID;
        }
    private:
        int generateID(){
            //some code that generate unique ID
        }
        int ID = generateID();
    };

    class FooB : public FooA{

    };

Will the ID initialized in the FooA goes also to the FooB? So for FooB I can use getID and for example get value from FooA::generateID.

Aucun commentaire:

Enregistrer un commentaire