tintin92:
Hello,
Is it not possible that a function return a object ?
'return' - structure have objects and cannot be copied OOP_FunctionReturnObject.mq4 27 4
Regards,
The Return operator "can't return any arrays, class objects, variables of compound structure type"; however, it can return an object pointer.
Hello Thirteen,
Is this correct ?
Should I have to delete the object or is it automatic?
//+------------------------------------------------------------------+ //| OOP_FunctionReturnObject.mq4 | //| Copyright 2014, Pierre8r | //| https://www.mql4.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2014, Pierre8r" #property link "https://www.mql4.com" #property version "1.00" #property strict //+------------------------------------------------------------------+ //| Script program start function | //+------------------------------------------------------------------+ void OnStart() { //--- CName* Paul; Paul= FunctionReturnObject(); } //+------------------------------------------------------------------+ class CName { // Here is the entire code of the class }; //+------------------------------------------------------------------+ CName *FunctionReturnObject() { CName *Jacques=new CName(); return(Jacques); } //+------------------------------------------------------------------+
tintin92:
Hello Thirteen,
Is this correct ?
Should I have to delete the object or is it automatic?
Once new is used you have to delete it by delete. Besides, it seem quite ok.

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Is it not possible that a function return a object ?
'return' - structure have objects and cannot be copied OOP_FunctionReturnObject.mq4 27 4
Regards,