MQL5中的OOP问题 - 页 96

 
class A
{
private:
   int _value;
public:
  void set(const int value)      { _value = value;    }
  int  get()                     { return(_value);    }
  template<typename Type>
  static void set(Type &a, const int value){ ((A*)&a)._value = value;  }
  template<typename Type>
  static int get(Type &a) { return ((A*)&a)._value;  }
};

class B: private A
{
public:
   void set(int a) {A::set(this,a);}
   int get() {return A::get(this);}
};

void OnStart()
{  
   B b;
   b.set(77);
   Print(b.get());
}

IMHO,但这样更漂亮。

 
Vladimir Simakov:

IMHO,但这样更漂亮。

我有纯粹的理论问题,我怀疑它们是否有任何实际应用。

谢谢!不错的代码