developer10

za NH

Jan 14th, 2016
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<iostream>
  2. using namespace std;
  3.  
  4.  
  5.  
  6. template<class T>
  7. class Test
  8. {
  9.     T foo;
  10.     int broj;
  11. public:
  12.     Test(double br)
  13.     {
  14.         foo = br;
  15.         broj = 0;
  16.     }
  17.  
  18.     T GetFoo()const { return foo; }
  19.  
  20. };
  21.  
  22. template<class T>
  23. ostream& operator<< <>(ostream& out, const Test<T>& obj)
  24. {
  25.     out << "Pi = " << obj.GetFoo() << endl;
  26.  
  27.     return out;
  28. }
  29.  
  30.  
  31. int main()
  32. {
  33.     double x = 3.14;
  34.  
  35.     Test<double> pi(x);
  36.  
  37.     cout << pi << endl;
  38.  
  39.     system("PAUSE>0");
  40.     return 0;
  41.  
  42. }
Add Comment
Please, Sign In to add comment