trouble creating new objects

 

Finally trying to look into new MQL5 language.

As far as being onject-oriented it's like going back in time about maybe 20 years back.

 But on the more concrete note: Right away I am stumped... What's wrong here?

 

class testclass
{};
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
{
 testclass newobj = new testclass;
}

'TestObject.mq5' TestObject.mq5 1 1
'new' - type mismatch TestObject.mq5 18 21
illegal operation use  1 1
2 error(s), 0 warning(s)  1 1
 

 

correct should be

testclass * newobj = new testclass();

... 

delete newobject; 

 

 
irusoh1:

Finally trying to look into new MQL5 language.

As far as being onject-oriented it's like going back in time about maybe 20 years back.

 But on the more concrete note: Right away I am stumped... What's wrong here?

 

class testclass
{};
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
{
 testclass newobj = new testclass;
}

'TestObject.mq5' TestObject.mq5 1 1
'new' - type mismatch TestObject.mq5 18 21
illegal operation use  1 1
2 error(s), 0 warning(s)  1 1
 

You can also learn more by reading the article - Writing an Expert Advisor Using the MQL5 Object-Oriented Programming Approach
Reason: