Thursday, July 9, 2009

What is pointers...pointer of c++ in oop language..?

i have an assignment.plz help me.if u'll help me God'll help u

What is pointers...pointer of c++ in oop language..?
When you declare a variable, " int num = 10 " for example, the program will allocated some space for num in the memory. So, that memory of num stores the value 10. When you want to use num, how would the program knows where to find it? It gotta have an address --- memory address. So, the pointers are object that points to the memory addresses.





Example:





int num = 10;


int* ptr = %26amp;num;





So, %26amp; is called "address-of operator" and ptr stores the memory address of the variable num.





To retrieve the value from the pointer ptr, you use * asteric - "dereference operator" to retrive the value that is stored in the address.





int num2 = *ptr;





Then num2 will have the value 10.
Reply:For homework help there are better websites like http://askexpert.info/
Reply:Pointers are variable that contains memory addresses as their values. It contains the address of a specific variable that contains a specific value.
Reply:Pointer is instruction directed to seek field or record or data.
Reply:Whats the question?Pointers are the same in C and C++. On the superficial level,poiters are just addresses of memory locations...but they're much more powerful when used the right way.
Reply:A pointer is a variable which stores an address location (in the computer's memory).





P.S. I don't believe in God.

magnolia

No comments:

Post a Comment