Thursday, December 4, 2014

cs Sep 9, 2014



ij = f(x)

ij has a memory address pointing to
f  -> dynamically allocate memory while the program is running , "run-time"


int f(); // declaration not definition;

int f()  // definition and declaration
{

  cin >> n ;
  new int ; // definition not declaration

}

static memory allocation versus dynamic memory allocation



cin << n;
new int[n] // legal...

class myclass; // declaration not definition

const int x = 0; identifier not variable.. chapter 3

operator >>(cin, n) evaluates to an object cin

operator +(n,2) evaluates to an integer object.

Review Chapter 3

3. int number ;  cin >> number;
4. newline  How many bytes of memory our  control character takes -- 1 bytes as \ is escape sequence in '\n'

assignment operator is right associative i.e. evaluated right to left y =(x=2),

(y+x)+2 left associative
5. Null terminator
6.

int a[5];
Or
vector <int> v;

for (int x: v)  // last line of assignment (19 in chapter 4).
cout <<x;

ideas of OOP

encapsulation

struct Data
{
   string name;
   double score;
}

then we could define vector<Data> v2;

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home