Singleton class leads to "unexpected token. probably type is missing"

Eugen Funk  

Hi, when I call a member method of my singleton class, I receive the error message "unexpected token, probably type is missing" during compilation.

This is the code

Config * cfg  = getEURUSD_m15_R3();
ConfigManager* cm = ConfigManager::getInstance();
cm.addConfig(cfg); // <-------------------------- RAISES ERROR


'cm' - unexpected token, probably type is missing? MyEa.mq5 125 1

When I delete that line


the EA can be compiled without errors.

And this would be the singleton class:

#include "ConfigTypes.mqh"
#include "Config.mqh"

class ConfigManager 
        //fillconfigs manually
    static ConfigManager* _instance; //Singleton instance
    ulong current_idx;

    static ConfigManager* getInstance(){
        if (!_instance) //if not valid yet
            _instance = new ConfigManager();
            if( _instance == NULL )     // this would be a catasrophic failure
                int err_code=GetLastError();
                string comment_string=__FUNCTION__+": ConfigManager Constructor failed, error: "+IntegerToString(err_code);
        return _instance;

    static Config* get(){
        Config * cfg=ConfigManager::getInstance().getConfig();
        return cfg;
    Config* selectConfig(string symbol, ENUM_TIMEFRAMES tf, RiskLevel risklevel);
    Config* configs[];
    Config* getConfig();
    void addConfig(Config * cfg);

    ConfigManager(ConfigManager const&){};          // Private Copy Constructor prevents copy of the object as part of Singleton pattern
    ConfigManager operator=(ConfigManager const&);  // Private Assignment Operator, prevents assignment as part of Singleton pattern


ConfigManager *ConfigManager::_instance=NULL;  // Initialize Global Pointer;

Config* ConfigManager::getConfig()
    return configs[current_idx];

void ConfigManager::addConfig(Config* cfg)
    arrayPush(configs, cfg);

Config* ConfigManager::selectConfig(string symbol, ENUM_TIMEFRAMES tf, RiskLevel risklevel)
    Config * invalid_res=NULL;
    for (int i=0; i<ArraySize(configs); i++)
        Config * cfg = configs[i];
        if (StringFind(symbol, cfg.symbol)>=0 && cfg.time_frame == tf && cfg.risk==risklevel)
            return cfg;
    return invalid_res; //check it via if(CheckPointer(pointer)==POINTER_INVALID)

I really dont get any ideas what the problem could be. Maybe some double includes of the Config classe, or wrong method declaration??

Thanks everyone for every hint!