Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. int main()
  2. {
  3. myclass<int> myvecA;
  4. myclass<int> myvecB(10);
  5. myclass<int> myvecC(5,-9);
  6. myclass<string> myvecD(6, "Hi");
  7.  
  8. cout << "A size: " << myvecA.size() << endl;
  9. cout << "B size: " << myvecB.size() << endl;
  10. cout << "C size: " << myvecC.size() << endl;
  11. cout << "D size: " << myvecD.size() << endl;
  12. system("Pause");
  13. return 0;
  14. }
  15.  
  16. #include<iostream>
  17.  
  18. template <class C>
  19. class vector{
  20.  
  21. public:
  22. vector(int x);{
  23. sizearr = x;}
  24.  
  25. explicit vector() : sizearr(0) {}
  26.  
  27. V size();
  28.  
  29. private:
  30.  
  31. V sizearr;
  32.  
  33. };
  34.  
  35. template <class V>
  36. V vector<V>::size() {
  37. return sizearr;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement