Pergunta

In the current semester at the university we are working on OOP with C++.
I would like to understand the difference between a pointer and a reference operator.

The differences that I understand are:
1. Cannot change the object that the reference variable is binded to
2. we can use the reference variables to refer to the binded object without having to type the & operator (in contrast with the pointers where we would write *pi = 5;)

Also,does a reference variable contain the address of the object that is binded to?
In example:

int i;
int &ri = i; 

Here ri contains the address of i?

And the reason why when overloading ++ operator in this example of enumeration we are using the dereference or reference(*) operators before the name of the function.

Nenhuma solução correta

Licenciado em: CC-BY-SA com atribuição
scroll top