Search code examples
c++typedef

Is there any way to make a typedef friend of a class?


... 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?


Solution

  • You can use the typedef normally in the friend declaration:

    class Server {
    public:
        typedef _Command<Server> Command;
        friend Command;
    };