This is in context of C++. Lets say you have a group of common variables that need to be accessed by multiple functions for example a couple of 2D vector consisting of a 50,000 x 5 Grid. How would one go about doing that?
I do not want to be passing those variables as arguments into the functions as that just increases the complication and the time needed.
At present I can think of two ways to overcome this issue.
- Pointers: The most obvious choice I can think of is to use pointers somehow to make sure that all the variables are accessible to the functions without passing them as variables.
- Class: Another Idea I can think of is to make a separate class for the functions where all the variables are shared class-wide anyways.
Both these ideas have their pros and cons, hence I am looking for a more efficient approach.
Aucun commentaire:
Enregistrer un commentaire