Advertisement
Ginsutime

Array Cherno 1

Feb 20th, 2022
1,028
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  1. #include <iostream>
  2. #include <array>
  3.  
  4. class Array
  5. {
  6. public:
  7.     Array(int size)
  8.     {
  9.         m_Data = (int*)alloca(size * sizeof(int));
  10.     }
  11. private:
  12.     int* m_Data;
  13. };
  14.  
  15. int main()
  16. {
  17.     //int size = 5;
  18.     //int array[5]; // allocated on stack, can't set to int array[size] since has to be a constant value
  19.  
  20.     //int* heapArray = new int[size]; // allocated on heap
  21.     //delete[] heapArray;
  22.  
  23.     int size = 5;
  24.     Array data(size);
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement