Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.47 KB | None | 0 0
  1.  
  2. #include "stdafx.h"
  3. #include <istream>
  4. #include <conio.h>
  5. #include <vector>
  6. #include<fstream>
  7.  
  8. using namespace std;
  9.  
  10. // Number of elements in an array
  11. template <typename T, int N> char (&array(T(&)[N]))[N];
  12.  
  13. class sphere
  14. {
  15. public:
  16.     int x,y,z;
  17. };
  18. class m_Array
  19. {
  20.    
  21.     int size;
  22.     sphere *arry;
  23. public:
  24.  
  25.     //constructor
  26.     m_Array(int size)
  27.     {      
  28.         arry = new sphere[size];
  29.  
  30.     }
  31.     float addSphere(int x,int y,int z)
  32.     {
  33.         int lenght=sizeof(this->arry);
  34.         this->arry[lenght].x=x;
  35.         this->arry[lenght].y=y;
  36.         this->arry[lenght].z=z;
  37.     }
  38.      sphere *resizeArray(int old_size, int new_size)
  39.      {
  40.         sphere *ret_array;
  41.         ret_array = new sphere[new_size];
  42.  
  43.         int i;
  44.         for(i=0; i < new_size && i < old_size; i++)
  45.             ret_array[i] = this->arry[i];
  46.         delete [] this->arry;
  47.         return ret_array;
  48.     }
  49.  
  50. /*  int *copyArray(int *arry)
  51.     {
  52.         Array second=arry;
  53.         return second;
  54.     }*/
  55.     ~m_Array()
  56.     {
  57.         delete []arry;
  58.     }
  59.  
  60. }
  61.  
  62.  
  63.  
  64. /*
  65. void loadSphere();
  66.  
  67. int _tmain(int argc, _TCHAR* argv[])
  68. {
  69.     return 0;
  70. }
  71.  
  72. void loadSphere()
  73. {
  74.     Array *arr;
  75.     Array ar= Array(30);
  76.     fstream myFile ("data.bin", ios::in | ios::out | ios::binary);
  77.  /*   myFile.seekp (0);
  78.     myFile.write ((char*)&ar, sizeof (Array));
  79.    
  80.     myFile.seekg (0);
  81.     myFile.read ((char*)arr, sizeof (Array) * 10);
  82.     myFile.close();
  83. }
  84. void saveSphere(Array arry)
  85. {
  86.   fstream myFile ("data.bin", ios::in | ios::out | ios::binary);
  87.   myFile.write ((char*)&arry, sizeof (Array));
  88. }
  89.  
  90.  
  91.  
  92. }
  93.  
  94. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement