+ 5

why (++x) *(++x) results into 49 when x=5?

1st Aug 2017, 4:49 AM
Devansh
121 Respuestas
+ 16
i will go fire up the pc!
1st Aug 2017, 7:53 AM
jay
jay - avatar
+ 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)
1st Aug 2017, 7:39 AM
jay
jay - avatar
+ 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
1st Aug 2017, 7:50 AM
jay
jay - avatar
+ 12
@4rontender: when using int x{5} you can change the value of x anytime. it is just another method of initializing a value
1st Aug 2017, 7:28 AM
jay
jay - avatar
+ 12
😂 why tho?
1st Aug 2017, 7:56 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 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
1st Aug 2017, 9:14 AM
jay
jay - avatar
+ 10
i can!
1st Aug 2017, 6:26 AM
jay
jay - avatar
+ 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 😄
1st Aug 2017, 9:18 AM
jay
jay - avatar
+ 10
please post this as a new question. your query now has nothing in common with the original posters topic
6th Sep 2017, 7:05 AM
jay
jay - avatar
+ 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.
6th Sep 2017, 7:18 AM
jay
jay - avatar
+ 9
Это от Google!
1st Aug 2017, 6:28 AM
jay
jay - avatar
+ 9
Google отлично работает, чтобы сделать меня русским
1st Aug 2017, 6:32 AM
jay
jay - avatar
+ 8
yep! wish I was bilingual
1st Aug 2017, 6:03 AM
jay
jay - avatar
+ 8
hahahah what?
1st Aug 2017, 6:10 AM
jay
jay - avatar
+ 8
Pancake and the scoff? whaaaa?
1st Aug 2017, 6:10 AM
jay
jay - avatar
+ 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
1st Aug 2017, 6:36 AM
jay
jay - avatar
+ 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
4th Sep 2017, 9:14 AM
jay
jay - avatar
+ 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
4th Sep 2017, 9:26 AM
jay
jay - avatar
+ 8
...I mean a complete new thread.
6th Sep 2017, 7:11 AM
jay
jay - avatar
+ 7
7*7 = 49.. seems right to me 😀
1st Aug 2017, 4:59 AM
jay
jay - avatar