+ 1

Pointers

Is the use of pointers a good or bad habit in programming?

28th Jun 2018, 9:33 AM
Mushi Ahmad
Mushi Ahmad - avatar
1 Réponse
+ 4
Using pointers is a good habit in programming as long as it's meaningful. What I mean by meaningful is that you should not use pointers to normal variable when the situation doesn't arise or not required. Like whenever you want to call by reference to a subroutine (i.e passing alterable variable to subroutine so that it does not have to duplicate the data and saves memory at runtime), This pointer in C++ or in C whenever you are handling strings or arrays,files,structure members,etc, then you can use pointers. But it is not necessary to declare pointers to variable if it's just a simple program algorithm, for example, like addition of two numbers.Because if one compares the runtime complexity of the two Algorithms, one with pointers for addition and the other without pointers of addition, then the runtime complexity of both the algorithm will be almost near and the overall time complexities will be almost approximate. Hence it's good to use pointers when it's really required in the programming.
28th Jun 2018, 11:20 AM
D-Key
D-Key - avatar