Frage

I just need:

Correct syntax of making a "class template" friend to a class

War es hilfreich?

Lösung 2

Given a class template, for example

template <typename> class Template;

you can either befriend a particular specialisation of the template:

friend class Template<int>;

or all specialisations:

template <typename> friend class Template;

Andere Tipps

If you want a different typed friend class:

template<typename,typename> friend class ClassName;

In C++11 you can do this:

template<typename T>
class C
{
    friend T;
};
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top