fork download
  1. #include <iostream>
  2. #include <iomanip>
  3.  
  4. using namespace std;
  5.  
  6. template<class T>
  7. class Array
  8. {
  9. private:
  10. //...
  11.  
  12. public:
  13. //...
  14. template<typename U>
  15. friend ostream& operator<<(ostream &os, const Array<U> &obj);
  16. };
  17.  
  18. template<class T>
  19. ostream& operator<<(ostream &os, const Array<T> &obj)
  20. {
  21. //..
  22. cout << __func__ << endl;
  23. return os;
  24. };
  25.  
  26. int main(int argc, const char * argv[])
  27. {
  28. Array<int> arr;
  29.  
  30. cout << "arr: " << arr << endl;
  31. }
  32.  
  33.  
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
arr: operator<<