Download MetaTrader 5

OOP for MQL4 - call from an Inherited class a method of the Parent class existing in both Classes

To add comments, please log in or register
Your conversation partner speaks foreign language? Automatic translation will help you!
lucat
192
lucat 2016.09.14 15:38 

I have a CBase class and a CDerived class (inherited by CBase).

Both them have the public method "Clear"

How can I call from the Derived class the "Clear" method of the Base class

 // example 

class CBase

  {

      int myCount;

public:

                     CBase(void);

                    ~CBase(void);

      void Clear()   {myCount=0;}

  };


  

class CDerived : public CBase

 {

      int myDerivedCount;

public:

                    CDerived (void);

                   ~CDerived (void);

      void Clear()

      {

         CBase.Clear();  // This not work! - Is it possible to call the Clear of the CBase class???

         myDerivedCount=0;

      }

                      

 }; 

Amir Yacoby
1195
Amir Yacoby 2016.09.14 16:11  
lucat:

I have a CBase class and a CDerived class (inherited by CBase).

Both them have the public method "Clear"

How can I call from the Derived class the "Clear" method of the Base class

 // example 

class CBase

  {

      int myCount;

public:

                     CBase(void);

                    ~CBase(void);

      void Clear()   {myCount=0;}

  };


  

class CDerived : public CBase

 {

      int myDerivedCount;

public:

                    CDerived (void);

                   ~CDerived (void);

      void Clear()

      {

         CBase.Clear();  // This not work! - Is it possible to call the Clear of the CBase class???

         myDerivedCount=0;

      }

                      

 }; 

CBase::Clear();
lucat
192
lucat 2016.09.14 20:36  
Amir Yacoby:
CBase::Clear();

THANKS A LOT

Works fine 

To add comments, please log in or register