vendredi 27 août 2021

Self static referential class

I have been given a task of compiling the C++ legacy code on a new platform. In the process of compiling, I came across the following code...

class GLOBALS
{
public:
    static GLOBALS _global;
};
GLOBALS GLOBALS::_global;

class DEF
{
public:
    GLOBALS::GLOBALS _global;
};

When I am trying to compile this code, I am getting following error...

error: ‘GLOBALS::GLOBALS’ names the constructor, not the type
GLOBALS::GLOBALS _global;

I am not getting what this code is trying to achieve here.. Can anyone enlighten me on this? And how they were able to compile the code previously?

Aucun commentaire:

Enregistrer un commentaire