View Full Version : QT and variable scope

29th November 2007, 18:28
I have a question that is borderline between Qt and C++.
The program I'm writing consists of many functions distributed between several *.cpp files. Many functions act on the same variables (about 10 total) and there is no reason to hide any variables from any of the functions (all can be public).
Which of the following is the best way to make all variables available to the relevant functions? By best I mean - which is the fastest?

a) Declare all under "public" in the single QWidget class that I use
b) Use variable passing between functions as needed
c) Give all variables global scope by declaring them outside of all functions

29th November 2007, 22:32
There is no borderline - everything that applies to C++, applies to Qt. Use whatever means you would have used in pure C++ application.