Clonar * class objeto

 

Como fazer para clonar os dados de um objeto de uma classe para um novo objeto do mesmo tipo de classe?


/+------------------------------------------------------------------+
//| Class                                                            |
//+------------------------------------------------------------------+
class CTest
  {
public:
                     string name;
                     int number;
                     CTest(void);
                    ~CTest(void);
  };

//+------------------------------------------------------------------+
//| Construtor                                                       |
//+------------------------------------------------------------------+
CTest::CTest()
  {
  }

//+------------------------------------------------------------------+
//| Destrutor                                                        |
//+------------------------------------------------------------------+
CTest::~CTest()
  {
  }

CTest *objects[];


//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   ArrayResize(objects,1,0);
   objects[0] = new CTest;
   
   objects[0].name = "Object_1";
   objects[0].number = 1;
//--- create timer
   EventSetTimer(1);
//---
   return(INIT_SUCCEEDED);
  }

//+------------------------------------------------------------------+
//| Timer function                                                   |
//+------------------------------------------------------------------+
void OnTimer()
  {
//---
   int size = ArraySize(objects);
   //---
   if(size < 10){
      Print("Creating: " + IntegerToString(size));
      ArrayResize(objects,size + 1,0);
      objects[size] = new CTest();
      objects[size].name = "Object_" + IntegerToString(size);
      objects[size].number ++;
      Print("Created: " + IntegerToString(size + 1));
      Print("");
   }else{
      for(int i = 0; i < size;i++){
         Print("Object: " + IntegerToString(i));
         Print("Name: " + objects[i].name);
         Print("Number: " + IntegerToString(objects[i].number));
         Print("");
      }
      ExpertRemove();
   }
  }

Nesse código na linha:  objects[size] = new CTest();
Estou criando um novo objeto mas gostaria de clonar os dados do objeto anterior.

Como clonar?

 
Resolvido com auxilio do amigo LanMM! @Arelian Monteiro Maia

//+------------------------------------------------------------------+
//|                                                         test.mq5 |
//|                                   Copyright 2022, Márcio Andrade |
//|                                 https://www.marcioandrade.com.br |
//+------------------------------------------------------------------+

//--- version        "1.00"
#property copyright "Copyright 2022, Márcio Andrade."
#property link      "https://www.marcioandrade.com.br"
#property version   "1.00"

//+------------------------------------------------------------------+
//| Class                                                            |
//+------------------------------------------------------------------+
class CTest
  {
public:
                     string name;
                     int number;
                     CTest(void);
                    ~CTest(void);
   void              Clone(CTest &ref_pointer){this = ref_pointer;};
  };

//+------------------------------------------------------------------+
//| Construtor                                                       |
//+------------------------------------------------------------------+
CTest::CTest()
  {
  }

//+------------------------------------------------------------------+
//| Destrutor                                                        |
//+------------------------------------------------------------------+
CTest::~CTest()
  {
  }

CTest *objects[];


//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   ArrayResize(objects,1,0);
   objects[0] = new CTest;
   
   objects[0].name = "Object_1";
   objects[0].number = 1;
//--- create timer
   EventSetMillisecondTimer(1);
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//--- destroy timer
   EventKillTimer();
  }

//+------------------------------------------------------------------+
//| Timer function                                                   |
//+------------------------------------------------------------------+
void OnTimer()
  {
//---
   int size = ArraySize(objects);
   //---
   if(size < 10){
      Print("Creating: " + IntegerToString(size));
      ArrayResize(objects,size + 1,0);
      objects[size] = new CTest();
      objects[size].Clone(objects[size - 1]);
      objects[size].number ++;
      objects[size].name = "Object_" + IntegerToString(objects[size].number);
      Print("Created: " + IntegerToString(size + 1));
      Print("");
   }else{
      for(int i = 0; i < size;i++){
         Print("Object: " + IntegerToString(i));
         Print("---");
         Print("Expected number: " + objects[i].name);
         Print("Real Number: " + IntegerToString(objects[i].number));
         Print("---");
      }
      for(int i=ArraySize(objects) - 1;i>=0;i--){ if(CheckPointer(objects[i]) != POINTER_INVALID) delete objects[i]; }
      ExpertRemove();
   }
  }
//+------------------------------------------------------------------+
 
Obrigado pela oportunidade de ajudar meu amigo.
Razão: