Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
accessing private of different type of template
#include <iostream> #include <string> template<class T> class ManagedObject { public: template<class U> void func(ManagedObject<U> & other) { std::cout << other.var << '\n'; } private: // without this the other ManagedObject of different type cannot access the private // of this managed object template<class> friend class ManagedObject; T var; }; int main() { ManagedObject<int> i; ManagedObject<std::string> s; s.func(i); }
run
|
edit
|
history
|
help
0
no-thread
javascritp
xyz1_1 programm
Time Zone Registry
Matrix_1
For NULL-embedded strings, CStringT::Find() produces what you may not expect
vaska
#8
error_check
Visual C++ template instantiation