0

... In my case:

    template<class X>
    struct _Command {
        char*   id;
        char*   description;
        char    messages[10][100];
        bool    (X::*function)();
    };

    Class Server {
        public:
            typedef _Command<Server>Command;
    }

How do I make Command friend of the Server class?

  • What is `Class`? – adziri Jan 28 '20 at 09:51
  • 1
    Unrelated to your problem, but please note that all symbols beginning with an underscore and followed by an upper-case letter (like e.g. `_Command`) is reserved in all scopes. See [What are the rules about using an underscore in a C++ identifier?](https://stackoverflow.com/questions/228783/what-are-the-rules-about-using-an-underscore-in-a-c-identifier) for more information. – Some programmer dude Jan 28 '20 at 09:52
  • `typedef`can be used inside the scope of other types... so here, except the misstypes and syntax errors, `Server::Command` can be declared. But it has nothing to do with friendship. – Sandburg Jan 28 '20 at 09:54

1 Answers1

0

You can use the typedef normally in the friend declaration:

class Server {
public:
    typedef _Command<Server> Command;
    friend Command;
};
VLL
  • 9,634
  • 1
  • 29
  • 54