Monday, May 12, 2014

Class of May 12, 2014

          Today was the last class of this semester. We reviewed for the final which is good because I want to get an A in the test in order to get an A in the course. I really learned a lot through out the semester and now I have to keep practicing in order to get better.

Wednesday, May 7, 2014

Class of May 7, 2014

          In today's class we discussed dynamic arrays. Dynamic arrays are arrays whose size is determined when the program is running, not when you write the program. I believe that these arrays are better than static arrays because they are more flexible and allow the user to determine the size.

Monday, May 5, 2014

Class of May 5, 2014

Happy Cinco de Mayo!!

          In today's class, we discussed pointers, the new operator, and the delete operator. Pointers tell us where a variable is located. It is really simple to understand.

To declare pointers:
ex: double *p;

The address of operator:
ex: p1 = &v1

The new operator creates a pointer to a new "nameless" variable of type int.
ex: p1 = new int

The delete operator immediately releases the memory space that will no longer be used by the program. This is a great tool since it prevents a program from taking all the memory.
ex: delete p;


Friday, May 2, 2014

Class of May 2, 2014

     In today's class, among many topics we discussed vectors. Vectors are like arrays that can change size as your program runs.

To declare a vector:

vector <int> v;

To access vector elements:

v[i] = 45;

cout << v[i];

To initialize vector elements we use the member function push-back. This adds the element in the next available position.

Don't forget to include the vector library!!

#include <vector>