vendredi 21 février 2020

C++ friended main function unable to access private members [duplicate]

In a header file I forward declare and then friend the main class:

int main(int argc, const char* argv[]);

namespace custom
{

template<typename T>
class something
{
public:
    friend int main(int argc, const char* argv[]);

    // ...
}

}

but when I compile it I get errors from the main function saying private members from that class are note: declared private here. The main function's signature is exactly the same (int main(int argc, const char* argv[])).

Aucun commentaire:

Enregistrer un commentaire