I'm a cs student working towards my degree. My road to graduation is still a pretty far deal. However, i want to make sure that im doing everything i can to surpass all the others cs students.
Anyways, i'm trying to wrap my head around why we use pointers or why ever bother using them in my code. I understand that a pointer points to an address. That address demonstrates the variable memory location.
So in essence, i can determine what address my variable have. However, assuming every user is using a computer, wouldn't the address change for that specific variable, since its a dynamic value (assigned by hardware etc.)?
The only time i feel i will need it is in a circumstance were i want to pass specific objects as parameters, but the only work around is through pointers (not there yet, thats why i can say what it would be).
Please if anyone wants to elaborate, please do. I want to understand memory management, and how it applies in our applications.
Thank You,
Jonathan V.
What I have tried:
unsigned short shortVar = 5;
std::cout << "shortVar: " << shortVar << std::endl;
std::cout << "Address of shortVar is: " << &shortVar << std::endl;