lundi 25 mars 2019

Second level Child access to Top Parent attribute [duplicate]

This question already has an answer here:

I'm facing to a problem,

I have a class Abstract in called for this example Parent

I have a class that is called Child1 that derived of Parent

I have a class that is called Child2 that derived of Child 1

I need for the correct Implementation that Child 2 have a T type inside declared with template

When i try to instanciate my Object Child 2 i have no problem, but when i tried to have access to a attribute (or member) of Parent, it says that i can't.

Parent Class

class Parent: 
{
protected : 
    std::atomic<bool> test
};


Child 1 Class

class Child1: public Parent
{

  public:
    some_method()
};


Child 2 Class

class Child2: public Child1
{

  public:
    some_method_that_need_to_use_test_variable()
};


I expected that in my method some_method_that_need_to_use_test_variable i can access to my member test that is defined on my top parent. I have instead :

error C3861: 'test' : identificateur introuvable

Aucun commentaire:

Enregistrer un commentaire