Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
accessing private of different type of template
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
#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); }
cl.exe
Show compiler warnings
[
+
] Compiler args
[
+
]
Show input
Compilation time: 1,93 sec, absolute running time: 0,22 sec, absolute service time: 2,17 sec
edit mode
|
history
|
discussion
54