+ 5
why (++x) *(++x) results into 49 when x=5?
121 Respuestas
+ 16
i will go fire up the pc!
+ 13
As i understand it {} puts value in at the time of creation. = put value in after creation
so int x = 5; ( create a null int, put value 5 in x)
int x { 5 }; create int with value 5 (int is never null)
+ 13
where ever you need create a new variable that needs an initial value you can use the {} method. using the = method is the same in most instances.
I have only encountered the {} method being required in creation of objects where the value is required at the time of the objects creation so far (classes). I will try and find some code in my library that shows this if you want
+ 12
@4rontender: when using int x{5} you can change the value of x anytime. it is just another method of initializing a value
+ 12
😂 why tho?
+ 11
lol, we have totally ruined this guys question...
I can't find it in my code.. I initally saw it in the book Learning c++ for Game Programming
Here is some info: http://www.informit.com/articles/article.aspx?p=1852519
+ 10
i can!
+ 10
@svengat, cause I ran into an instance that required me to use {} instead of = the other day and I cannot remember the code off the top of my head 😄
+ 10
please post this as a new question. your query now has nothing in common with the original posters topic
+ 10
If you are on the mobile app. Click the speech bubble icon which is in the main menu.
Click the green pen circle icon to create a new question. Fill in the appropriate fields as required.
Be sure to enter the appropriate tags and a descriptive title for your question (e.g Tag: c++,) as this enables other users to quickly assess if they have the knowledge required to help you.
+ 9
Это от Google!
+ 9
Google отлично работает, чтобы сделать меня русским
+ 8
yep! wish I was bilingual
+ 8
hahahah what?
+ 8
Pancake and the scoff? whaaaa?
+ 8
Speaking of, I was watching some youtube last night.. everything is sooooo cheap there! 50 us cents for a 1 hour train trip wtf!! its like 6 usd here
+ 8
makes me sigh they still teach void main() usage.
c will be 1 (or true) due to the statement
a!=10 ( a is not equal to 10)
but there is an error in what you wrote as c is undeclared.. missing a bool
+ 8
@Anuj: See logical operators.
http://en.cppreference.com/w/cpp/language/operator_logical
! means not. it will convert to boolean automatically if it is not already one
+ 8
...I mean a complete new thread.
+ 7
7*7 = 49.. seems right to me 😀