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

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

php - Accessing static methods using newly created $obj or using class Name -