Sunday, 5 January 2014

Jan 5

Place - Bangalore

Started to learn void pointer, What are the use of void pointer and how you declare it.
Void Pointer
It is useful when you want to write a module that works for all type then void pointer is very useful.
We ll discuss how to declare void pointer and deference the void pointer.

Initialization void pointer
   
void *ptr;    // ptr is declared as Void pointer

char cnum;
int inum;
float fnum;
Suppose we have assigned integer Address to void pointer then -
ptr = &inum;  // ptr has address of integer data
then to De-reference this void pointer we should use following syntax -
*((int*)ptr)
Now in C++ then how with a new syntax to de-reference the variable
void *value;
print(*static_cast<float*>(value));
Today is the last day in bangalore and from tomorrow college start. Stay tuned for new adventure to come. Done with SRM 303, Need to write a blog on that.

 And read an interesting blog on conversion of top-down to bottom-up approach
http://www.quora.com/Dynamic-Programming/While-solving-a-dynamic-programming-problem-I-can-figure-out-the-top-down-approach-pretty-quickly-but-I-am-failing-to-convert-it-into-bottom-up-in-some-of-the-cases-How-should-I-approach-bottom-up-once-I-figure-out-the-top-down-approach

No comments:

Post a Comment