2. Pointers and Memory

2. Pointers and Memory

Postby Cuchulainn » Wed Jan 21, 2009 1:03 pm

What is stack, heap and static memory?



Describe how to create heap-based objects, avoiding the common problems that novices have with raw pointers.



What is



double** mat;

double* mat[10];

double mat[10][20];



How would you initialise the matrix in each case; how do you manage memory?



//

??

pointe vs reference

dereferencing

null pointer

uninitialised pointer
User avatar
Cuchulainn
 
Posts: 673
Joined: Mon Dec 18, 2006 2:48 pm
Location: Amsterdam, the Netherlands

Re: 2. Pointers and Memory

Postby Excel4Net » Wed Jan 28, 2009 3:24 am

What is the auto_ptr? When would you use auto_ptr instead of a pointer?



What is the benefits of using auto_ptr compared tp shared_ptr of the Boost library?



What is the caveats of using auto_ptr?
User avatar
Excel4Net
 
Posts: 8
Joined: Fri Dec 26, 2008 2:42 am

Postby Cuchulainn » Wed Jan 28, 2009 11:56 am

Is the boost scoped_ptr a 'better' auto_ptr?



Is scope_ptr ~ const auto_ptr?
User avatar
Cuchulainn
 
Posts: 673
Joined: Mon Dec 18, 2006 2:48 pm
Location: Amsterdam, the Netherlands

Postby Cuchulainn » Mon Dec 28, 2009 3:37 pm

int* m;

delete m;



int* n = new int;

delete n;

delete n;



int* p = new int[20];

delete p;



int* q = new int[20];

delete q;

delete [] q;





int* t = new int[20];

delete [] t;

delete t;



{

int* r = new int;

}



int* p1 = p1;
User avatar
Cuchulainn
 
Posts: 673
Joined: Mon Dec 18, 2006 2:48 pm
Location: Amsterdam, the Netherlands


Return to C++ Certification and Examinations: Intermediate Level

Who is online

Users browsing this forum: No registered users and 0 guests

cron