Advertisement
Guest User

sda

a guest
May 30th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3.  
  4.  
  5. using namespace std;
  6.  
  7. template <class T> class A
  8.  
  9. {
  10. public:
  11. A()
  12. {
  13.  
  14. }
  15. ~A(){}
  16. T dubleaza (T param)
  17. {
  18. return 2 * param;
  19. }
  20. T a;
  21. std::vector <T> vec;
  22. void print()
  23. {
  24. int i;
  25. for(i=0;i<vec.size();i++)
  26. cout<<vec[i];
  27. }
  28.  
  29.  
  30.  
  31. };
  32.  
  33. class Punct
  34. { public:
  35. Punct(){};
  36. Punct(int a,int b)
  37. {
  38. x=a;
  39. y=b;
  40. }
  41. friend std::ostream& << (std::ostream operator os, const Punct &m)
  42. {
  43. os<<m.x<<" "<<m.y<<endl;
  44. return os;
  45. }
  46. int y,x;
  47. };
  48.  
  49. class Triunghi
  50. {
  51. Triunghi () {}
  52. std::vector <Punct> v;
  53. };
  54.  
  55.  
  56. int main()
  57. {
  58. A<int> o;
  59. o.a=2.2;
  60. cout<<o.a<<endl;
  61. A<double> f;
  62. f.a=2.2;
  63. cout<<f.a<<endl;
  64. f.a=f.dubleaza(2.2);
  65. cout<<f.a<<endl;
  66.  
  67. A<int> var;
  68. A<Punct> d;
  69. d.vec.push_back(Punct(1,1));
  70. d.vec.push_back(Punct(2,1));
  71. A<Triunghi> tr;
  72. tr.v.push_back(Punct(3,7));
  73. tr.v.push_back(Punct(2,1));
  74. tr.v.push_back(Punct(5,2));
  75.  
  76.  
  77.  
  78.  
  79. return 0;
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement