C++ Pointers and References when picking objects


I have dummy question for references and pointers in C++ Rhino picking objects.
It is more lack of knowledge of language.

In the example below and object is picked from rhino.
In one case the object is declared as reference in other as a pointer.
Can variables (obj_ref and obj) be declared both as pointers or both as references?
What would be core difference in programming between pointers and references, for me it is very similar concept just references cannot be changed.

	CRhinoGetObject go;
	go.SetCommandPrompt(L"Select object");
	CRhinoGet::result res = go.GetObjects(1,1);

	if (res == CRhinoGet::object) {
		const CRhinoObjRef& obj_ref = go.Object(0);//reference
		const CRhinoObject* obj = obj_ref.Object();//pointer

		if (obj) {

Hi @Petras_Vestartas,

In this case, you could do this:

if (res == CRhinoGet::object) 
  const CRhinoObjRef& obj_ref = go.Object(0);
  const CRhinoObject& obj = *obj_ref.Object();

Well, there is a crap ton of information available on this if you search. But briefly:

Pointers - A pointer is a variable that holds memory address of another variable.

References - A reference variable is an alias, that is, another name for an already existing variable.

I’ll let you search the web to fill in the details.

– Dale

Thank your good explanation.

And both of them cannot be pointers?
(even the type is named by ref)