Saturday, July 13, 2019

C++, when do I want to use a pointer to a variable instead of a variable itself?

I'm an (almost) 3rd year computer science student. I had a C++ programming module, but it did not go into details, just covered the basics. It introduced us to pointers, but I'm still wondering this:



Why (in what cases or circumstances) would one want to use a pointer to an int, as opposed to simply making an int itself? In other words, what are some good situations where using a pointer to a variable is better than simply declaring and initializing the variable itself? When are pointers to variables better than variables themselves?

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...