fork download
  1. #include <iostream>
  2.  
  3. class st4vector
  4. {
  5. public:
  6. st4vector(int indim); //standartinit
  7. ~st4vector(); // destructor
  8.  
  9. int dim;
  10. double* t;
  11. double* x;
  12. double* y;
  13. double* z;
  14. };
  15.  
  16. using namespace std;
  17.  
  18. int main()
  19. {
  20. st4vector velocity(200);
  21.  
  22. cout << velocity.x[0] << endl;
  23.  
  24. return 0;
  25. }
  26.  
  27. st4vector::st4vector(int indim) {
  28. dim=indim;
  29.  
  30. t=new double [dim];
  31. x=new double [dim];
  32. y=new double [dim];
  33. z=new double [dim];
  34.  
  35. for(int i=0;i<dim;i++) {
  36. t[i]=0;
  37. x[i]=0;
  38. y[i]=0;
  39. z[i]=0;
  40. }
  41. }
  42.  
  43. st4vector::~st4vector()
  44. {
  45. if(t){
  46. delete [] t;
  47. delete [] x;
  48. delete [] y;
  49. delete [] z;
  50.  
  51. t=0;
  52. x=0;
  53. y=0;
  54. z=0;
  55. }
  56. }
  57.  
  58.  
Success #stdin #stdout 0.01s 2856KB
stdin
Standard input is empty
stdout
0