fork download
  1. namespace MyNamespace
  2. {
  3. template <typename Type>
  4. class Container;
  5.  
  6. namespace AccessPrivateImplementation
  7. {
  8. template <typename Type>
  9. Type getValue(Container<Type>* container);
  10. }
  11.  
  12. template <typename Type>
  13. class Container
  14. {
  15. friend Type AccessPrivateImplementation::getValue<>(Container<Type>* volume);
  16. private:
  17. Type value;
  18. };
  19.  
  20. namespace AccessPrivateImplementation
  21. {
  22. template <typename Type>
  23. Type getValue(Container<Type>* container)
  24. {
  25. return container->value;
  26. }
  27. }
  28. }
  29.  
  30. int main(int argc, char* argv[])
  31. {
  32. MyNamespace::Container<int> cont;
  33. MyNamespace::AccessPrivateImplementation::getValue(&cont);
  34. return 0;
  35. }
  36.  
Success #stdin #stdout 0s 2848KB
stdin
Standard input is empty
stdout
Standard output is empty