ABC &bca=abc;// is a reference
ABC *bca=abc;// is a pointer
only difference is reference cannot be null and once assigned it cannot be re-assigned.A pointer can be null, and can be made to point to different variables.However internally compilers implement references using pointers.
only difference is reference cannot be null and once assigned it cannot be re-assigned.A pointer can be null, and can be made to point to different variables.
No, that's not the only difference. The syntax for using a reference is different from the syntax for using a pointer. References have no equivalent of pointer arithmetic.
Please don't confuse people by giving them misleading information.
ABC* ptr; create a pointer that can point to any object of type ABC.
a pointer is no more than a 4byte variable (on 32bit platforms), it is NOT a complete object of that class.
the task of a pointer is to hold the memory address of some object.
in this case you say that the pointer POINTS to that object.
you can use the referencing operator "&"to get the address of any object (even the address of a pointer), use it like this: ptr = & object;
you can use the de-referencing operator "*" to get the object pointed to by your pointer:
1 2
ABC object_2;
object_2 = (*ptr);
ABC object; creates a full instance of the class ABC
Milky Buoy, please give a detailed explanation so that itllb convenient for amit
There's absolutely no point me spending time re-typing information that is already readily available out there online. I'm happy to help with problem-solving, and to help identify and fix problems with people's code, as my posting history here shows. But if information is easily found elsewhere, I don't see the purpose in retyping it.
It would have been trivial for Amitk to type a Google search - or consult his/her textbook - to find the information they were looking for in seconds.