other

murata mql class基礎

//+------------------------------------------------------------------+
//|                                                   test_class.mq5 |
//|                        Copyright 2020, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2020, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {

   
   Person myPerson1;
   myPerson1.name = "John";
   myPerson1.age = 37;
   
   Person myPerson2;
   myPerson2.name = "Enemy";
   myPerson2.age = 44;
   
   Alert(myPerson1.name, "   ", myPerson1.age);
   Alert(myPerson2.name, "   ", myPerson2.age);
   
   
   myPerson1.speak();
   
   myPerson2.speak();
   
   
  }
//+------------------------------------------------------------------+


class Person{

   public:
      string name;
      int age;
   
   public:
      void speak(){
      Alert("My name is: ", name, " and I am ", age, " years old");
      
      }
   
      
   
   
};
Was this helpful?