As your topic does not relate directly to the installation or operation of the IDE it has been moved to the Programming Questions category of the forum
In small sketches, global variables (I dare to assume that's what you meant) can be convenient and easier.
As sketches grow, however, passing variables will make more sense and serve to help you contain things, as well as allowing you to use names freely without fear of code fusing confusing what variables you think you are taking about.
It also usually means it is easier to use one function in many places.
As for efficiency, the microprocessor is hella fast, and it is unlikely that you'll be doing anything where that would be the basis for choosing.
Learn the language and use the right design for the situation. Don't worry about efficiency, these processors are faster than the machines that used to run fortune 500 companies just a few years ago. BTW, it is NEVER codes, it is just CODE.
Sorry for the bit of confusion, i am a beginner that had started c++ for 4 months
I means global variables, im not sure what global variables are. (Maybe Static and object variables?)
I have been learning java for a few months and understand some basic codes, so i was not considering of using objective variables in c++ because i think i need to create object to use it?!