Guest User

Vector.cc

a guest
Dec 1st, 2011
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. #include <iostream>
  2. #include "Vector.h"
  3.  
  4. Vector::Vector()
  5. {
  6.     v_P = 3;
  7.     v_col = new int[v_P];
  8.     for(int k = 0; k < v_P; k++) v_col[k] = 0;
  9. }
  10.  
  11. Vector::~Vector()
  12. {
  13.     delete[] v_col;
  14. }
  15.  
  16. void Vector::construct(int P)
  17. {
  18.     v_P = P;
  19.     for(int k = 0; k < P; k++) v_col[k] = 0;
  20. }
  21.  
  22. void Vector::set(int P, int val)
  23. {
  24.     v_col[P] = val;
  25. }
  26.  
  27. void Vector::print()
  28. {
  29.     std::cout << "[ ";
  30.     for(int k = 0; k < v_P; k++) std::cout << v_col[k] << " ";
  31.     std::cout << "]";
  32. }
  33.  
  34.  
Advertisement
Add Comment
Please, Sign In to add comment