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
not a parameter pack
Regex pipe and tabs c++
class with unique_ptr to vector
std::function ambiguity vc++
5sdgts
success
C++ exception
Overload resolve function pointer
return reference (msvc)
MSVC_example_GetAllocLength