c++ - How to use friend keyword for template class -
lets have 2 template classes, , b. if want make b friend of a, ?
class<template t> class { public: friend class b<t>; // ??? }; class<template t> class b { };
to use symbol, must declared or defined, same in template. need forward declare template b
. syntax(class<template t>
) declare template class not valid, should template <class t>
.
this should work:
template <typename t> // typename can replaced class class b; template <typename t> class { public: friend class b<t>; }; template <typename t> class b { };
Comments
Post a Comment