#include #include using namespace std; template class wrapper { T t; public: wrapper(const T& initial_t = T()): t(initial_t) {} friend void inside(const wrapper& w) {cout << w.t << "\n";} friend void outside(const wrapper& w); //friend T f() {return T();} //won't compile //friend void g() {cout << wrapper().t << "\n";} //shouldn't compile }; inline void outside(const wrapper& w) {cout << w.t << "\n";} inline void outside(const wrapper& w) {cout << w.t << "\n";} inline void outside(const wrapper& w) {cout << w.t << "\n";} int main() { cout << boolalpha << fixed; //see what type of zero we're printing inside(wrapper()); outside(wrapper()); outside(wrapper()); outside(wrapper()); return EXIT_SUCCESS; }