CS 225 Lecture Notes - Lecture 6: Compile Time, Memory Address

41 views3 pages

Document Summary

Mp2 available, due 9/13, 11:59p ec: 9/6 11:59p. // for static arrays, the size must be known at compile time. Arrays: dynamic (heap) int *x;// in contrast to x[8] int size = 3; x = new int[size]; // size can be set at runtime. // by runtime it means it can set through io. // creates size amount of space on heap and returns. // the first memory address back to int pointer x for(int i = 0; i < size, i++) x[i] = i+3; // last element will be i+3 delete [] x; A point to ponder: how is my garden implemented? class garden{ public: Cs 225 - lecture page 1 private: flower ** plot; // it could be a 2-d array of flowers how would we initialize it? plot = new int* [size] // plot is a pointer that points to something that points to a flower.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents