So i am currently taking a course called data structures and algorithms, and for the first lesson i got a question that i can't quite rap my head around.. The teacher is trying to demonstrate the values of using a call by value and call by reference. He is passing a data struct to a function that prints the addresses of the data struct.
The code is basically this:
struct Exempelstruct{
int m_intValue1;
int m_intValue2;
float m_array[1000];
};
void skrivAdresser1(Exempelstruct theStruct){
writeAdresses( theStruct );
}
//and
void skrivAdresser2(const Exempelstruct &theStruct){
writeAdresses( theStruct );
}
The question is why the addresses in the skrivAdresser1()
function lower than the addresses that are printed by skrivAdresser2()
?