int* ptr; *ptr = 10; #but ptr = new int; #without ampersand and dereference !!
Blog about programming and new technologies in general I've created for myself, to memorize briliant solutions of problems, my own parts of code written previously and some general ideas of workarounds. You can find here Python, Java, JavaScript, C++, Django, jQuery.
Showing posts with label pointers. Show all posts
Showing posts with label pointers. Show all posts
June 8, 2010
Tip of the Day #2 - pointers
Remember
June 7, 2010
Constant pointers, pointers to constants ?
What is the difference between:
float fVar = 3.14; const float* ptr1 = &fVar;and:
float fVar = 3.14; float* const ptr2 = &fVar;? The first one is pointer to constant value, so we can't change the value of variable the pointer points to :
*ptr1 = 10;The second one in contrary is a constant pointer to a value, and because of that we can't readdress it to point at different variable :
float fVar2; *ptr2 = &fVar2;
Subscribe to:
Posts (Atom)