86 lines
2.2 KiB
MQL5
86 lines
2.2 KiB
MQL5
|
|
//+------------------------------------------------------------------+
|
||
|
|
//| My_Object_Test.mq5 |
|
||
|
|
//| Eduardo Zucarato |
|
||
|
|
//| zucarato@gmail.com |
|
||
|
|
//+------------------------------------------------------------------+
|
||
|
|
#property copyright "Eduardo Zucarato"
|
||
|
|
#property link "zucarato@gmail.com"
|
||
|
|
#property version "1.00"
|
||
|
|
|
||
|
|
//--- example for CObject::Prev()
|
||
|
|
#include <Object.mqh>
|
||
|
|
|
||
|
|
class CObjectTest : public CObject
|
||
|
|
{
|
||
|
|
|
||
|
|
private:
|
||
|
|
static *CObjectTest last_object;
|
||
|
|
|
||
|
|
public:
|
||
|
|
|
||
|
|
CObjectTest() { last_object=NULL; } //Firt object must use this constructo
|
||
|
|
|
||
|
|
CObjectTest( CObjectTest *the_last ) // Next object must use this constructo
|
||
|
|
|
||
|
|
string test_text;
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
};
|
||
|
|
//+------------------------------------------------------------------+
|
||
|
|
//| Parametric constructor |
|
||
|
|
//+------------------------------------------------------------------+
|
||
|
|
CObjectTest :: CObjectTest (CObjectTest *the_last)
|
||
|
|
{
|
||
|
|
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
//+------------------------------------------------------------------+
|
||
|
|
//| Script program start function |
|
||
|
|
//+------------------------------------------------------------------+
|
||
|
|
void OnStart()
|
||
|
|
{
|
||
|
|
//---
|
||
|
|
CObjectTest *my_test, *my_first;
|
||
|
|
|
||
|
|
my_first = my_test = new CObjectTest;
|
||
|
|
|
||
|
|
my_test.test_text = "First instance text";
|
||
|
|
|
||
|
|
Print("my_first.test_text = ",my_first.test_text);
|
||
|
|
|
||
|
|
Print("my_test.test_text = ",my_test.test_text);
|
||
|
|
|
||
|
|
Print("End of test 1");
|
||
|
|
|
||
|
|
my_test = new CObjectTest;
|
||
|
|
|
||
|
|
my_test.test_text = "Second instance text";
|
||
|
|
|
||
|
|
Print("my_first.test_text = ",my_first.test_text);
|
||
|
|
|
||
|
|
Print("my_test.test_text = ",my_test.test_text);
|
||
|
|
|
||
|
|
Print("End of test 2");
|
||
|
|
|
||
|
|
|
||
|
|
//CObjectTest my_test2 = my_test.Prev();
|
||
|
|
my_test = my_test.Prev();
|
||
|
|
|
||
|
|
Print("my_first.test_text = ",my_first.test_text);
|
||
|
|
|
||
|
|
Print("my_test.test_text = ",my_test.test_text);
|
||
|
|
|
||
|
|
Print("End of test 3");
|
||
|
|
|
||
|
|
|
||
|
|
delete my_test;
|
||
|
|
delete my_first;
|
||
|
|
|
||
|
|
}
|
||
|
|
//+------------------------------------------------------------------+
|