+ 1

about the variabile name rules, if I try to call a variable "cout", or any other reserved word, will it result into an error, or is it just a good practice?

15th Jun 2016, 3:02 PM
naghree
4 Respostas
+ 1
it will generate an error
15th Jun 2016, 5:30 PM
Sardor
Sardor - avatar
+ 1
yes it will give error and it is a bad practice
16th Jun 2016, 11:28 AM
DJ Shiva & DJ Baba Shiv-Shekhar
DJ Shiva & DJ Baba Shiv-Shekhar - avatar
0
you know any keyword like cout or something else has pree defined word it has some special meaning like when we know about my mobile balance then we have to type some special key like *123# here is same that is reserved keyword to know balance
15th Jun 2016, 3:24 PM
Rajesh Sharma
Rajesh Sharma - avatar
0
Basically, any "keyword" in C++ along with other things such as numbers, operators and basically any syntax used in the language. For example: int 1 = 2; int 2 = 2; cout << 1 + 2; The reason why you can't name variables these things is because the compiler can't tell the difference between the variable called 1 and the number 1, so how does it know whether to output 3 or 4? A way around this would be to use the variable names int1 and int2, because they aren't part of the C++ syntax and therefore the compiler won't get confused. I would recommend using a variable identifier like "output" as an alternative to "cout".
21st Jun 2016, 8:02 PM
Connor Marshall
Connor Marshall - avatar