0
Can anyone enlighten me better, btw global variable and class, I sense the same definition been given to them. Is there any diffrence or are they d same
2 Antworten
+ 7
A global variable is a variable that is declared outside of any function or class, so that they can be accessed absolutely anywhere. In most cases, global variables are considered bad programming practice, so stay away from them. Just stay with declaring variables inside functions and classes.
A class is a block which contains different functions and variables, inside of three access specifiers: public, protected and private. An example of a class would be in a game, you'd have an enemy (which can have its own class), and the player (its own class again). That's the real basics of a class, anyway. But where C++ really shines is when polymorphism and inheritance is used, and is the reason classes are so great.
0
cool anwser thanks