In all of the projects I've created in my college classes I've always declared the variables that will be used in multiple methods (passed by reference) in my main method and then passed as needed, allowing for the main method to be nothing more than a control for what variable goes where. I understand that this is fine, but would it be an acceptable practice to make a header with all of the variables that will be used in many methods defined as extern so that I can call the variables without having to constantly pass them by reference into methods? I was thinking this might be an acceptable practice because often I find myself having to pass a variable to a method by reference in order to then pass it to another method (using the first method as nothing more than a connector) so it can be used properly. Thanks for the input in advance!
theories
0
Newbie Poster
Recommended Answers
Jump to Post>would it be an acceptable practice to make a header with all of the
>variables that will be used in many methods defined as extern
You're substituting one problem for another. In this case, the inconvenience of passing data around versus the nightmare of global variables in all but the …
All 4 Replies
Narue
5,707
Bad Cop
Team Colleague
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
theories
0
Newbie Poster
ArkM
1,090
Postaholic
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.