+ 2
C++ Variables
Im having a bit of trouble fully understanding the concept of the variable. A lot of random words got tossed out of nowhere and I little clue to what the explanation is actually trying to explain. Can someone dumb down the explanation of variables a bit for me?
2 Respostas
+ 1
Variables are like boxes, sort of. You can store letters and numbers in them ( by saying var_name = value) and name them almost anything you want. However, there are a few rules: the name has to only include numbers, letters and _. They also cannot be the name of reserved keywords (See https://en.cppreference.com/w/cpp/keyword). Also, they have to have a type (string, int, double, etc.). You can learn more about variable types and variable in general here: https://beginnersbook.com/2017/08/cpp-variables/#:~:text=Types%20of%20variables&text=int%3A%20These%20type%20of%20of,double-precision%20floating%20point%20value.
+ 1
Variables are stuff that you set a type and a value. For example it could be a Char with the value 'c'. We will name it "mychar".
Assuming that is NOT a constant, you can later change the value of mychar to any other character.