Advertisement
Guest User

Untitled

a guest
Feb 24th, 2020
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. int main () {
  2. int a = 5; // хранится в стэке
  3. double b = 4.4; // хранится в стэке
  4. Point c = {1.1, 3.2}; // хранится в стэке
  5. c.x = 2.1;
  6.  
  7. // new, delete
  8. // стэк: тип_переменной имя_переменной
  9. // куча: тип_переменной* имя_переменной = new тип_переменной;
  10. int* a1 = new int;
  11. *a1 = 7;
  12.  
  13. int a0 = 2, a2 = 3, a3 = 4;
  14. a2 = a0;
  15. a0 = a3;
  16.  
  17.  
  18. Point* c1 = new Point;
  19. *c1 = {1.1, 3.2};
  20. (*c1).x = 2.1; // <=> c1->x = 2.1;
  21.  
  22. Point* c3 = nullptr;
  23. Point* c2 = c1;
  24. c2->y = 1.1;
  25. cout << c1->y;
  26. c2 = nullptr;
  27. return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement