Need some help on weird compile error

 

I tried to compile following code from:

https://www.mql5.com/en/articles/260

There is a zip at bottom of the page. But I got compile error:

'NodeInfo' - conversion is not accessible because of inheritance access	Elliott_wave_en.mq5

But If i change .Add(NodeInfo) to something like .Add(NodeInfo.Node) or other objects the compile will pass. Any idea why only "NodeInfo" does not work? Thanks


//+------------------------------------------------------------------+
//| The Already function                                             |
//+------------------------------------------------------------------+
bool Already(TWave *Wave,int NumWave,TNode *Node,string Subwaves)
  {
   // obtain the necessary parameters of the wave or the group of waves
   int IndexStart=Wave.IndexVertex[NumWave-1];
   int IndexFinish=Wave.IndexVertex[NumWave];
   double ValueStart = Wave.ValueVertex[NumWave - 1];
   double ValueFinish= Wave.ValueVertex[NumWave];
   // in the loop, proceed the array NodeInfoArray for the search of the marked-up section of the chart
   for(int i=NodeInfoArray.Total()-1; i>=0;i--)
     {
      TNodeInfo *NodeInfo=NodeInfoArray.At(i);
      // if the required section has already been marked-up
      if(NodeInfo.Subwaves==Subwaves && (NodeInfo.ValueStart==ValueStart) && 
         (NodeInfo.ValueFinish==ValueFinish) && (NodeInfo.IndexStart==IndexStart) &&
         (NodeInfo.IndexFinish==IndexFinish))
        {
         // add the child nodes of the found node into the child nodes of the new node
         for(int j=0;j<NodeInfo.Node.Child.Total();j++)
            Node.Child.Add(NodeInfo.Node.Child.At(j));
         return(true); // exit the function
        }
     }
   // if the interval has not been marked-up earlier, then record its data into the array NodeInfoArray
   TNodeInfo *NodeInfo=new TNodeInfo;
   NodeInfo.IndexStart=IndexStart;
   NodeInfo.IndexFinish=IndexFinish;
   NodeInfo.ValueStart=ValueStart;
   NodeInfo.ValueFinish=ValueFinish;
   NodeInfo.Subwaves=Subwaves;
   NodeInfo.Node=Node;
   NodeInfoArray.Add(NodeInfo);	 // <-- compiler error: 'NodeInfo' - conversion is not accessible because of inheritance access	Elliott_wave_en.mq5	657	22

   return(false);
  }

 
benqethan:

I tried to compile following code from:

https://www.mql5.com/en/articles/260

There is a zip at bottom of the page. But I got compile error:

But If i change .Add(NodeInfo) to something like .Add(NodeInfo.Node) or other objects the compile will pass. Any idea why only "NodeInfo" does not work? Thanks


Could you try adding parentheses to 'new TNodeInfo' ?
 
benqethan:

I tried to compile following code from:

https://www.mql5.com/en/articles/260

There is a zip at bottom of the page. But I got compile error:

But If i change .Add(NodeInfo) to something like .Add(NodeInfo.Node) or other objects the compile will pass. Any idea why only "NodeInfo" does not work? Thanks


I think you have to insert "public" in declaration class TNodeInfo (class TNodeInfo:public CObject).

 
Petr Nosek:

I think you have to insert "public" in declaration class TNodeInfo (class TNodeInfo:public CObject).

That solves the issue. Do you mind explain a little bit. I have background of c++ but the exception looks unfamiliar for me.
 
The array class takes instances of CObjects. Public derivation "is a" relation, so it works. Non-public derivation means it is not a "is a" relation but uses the base class internally (it's a "has a" relationship.)
          C++ Tutorial: Private Inheritance - 2018
 
Petr Nosek:

I think you have to insert "public" in declaration class TNodeInfo (class TNodeInfo:public CObject).

Cheers!