+ 2

hi friends thank you watch this question ,i want to know why te last output "name" like that

https://code.sololearn.com/cwD5Z933h70B/?ref=app

2nd Aug 2017, 1:32 PM
ćœ­æ°
ćœ­æ° - avatar
10 Respostas
+ 10
Then what is it. If you do not elaborate on your question, it would be hard to help you.
2nd Aug 2017, 4:04 PM
Hatsy Rei
Hatsy Rei - avatar
+ 8
Putting the bad practices aside: name was originally initialized with 5. You created multiple instances of the same class. You called input() on s2, which will display name value as your input value. Your last output on name is on s3, a newly initialized instance of the class, so name will be 5.
2nd Aug 2017, 1:55 PM
Hatsy Rei
Hatsy Rei - avatar
+ 8
it is junk value. could be any number. â˜ș odd that it differs
2nd Aug 2017, 6:10 PM
jay
jay - avatar
+ 7
not sure I understand your question.. because it uses the default value 5
2nd Aug 2017, 1:53 PM
jay
jay - avatar
+ 7
when code references an uninitialized value. it can print any value. i.e int x; cout << x; but it 'should' print 5 in your code. thus 'odd'
2nd Aug 2017, 9:42 PM
jay
jay - avatar
+ 1
I'm sorry but the name of s3 it's not 5 on Code::Blocks
2nd Aug 2017, 2:14 PM
ćœ­æ°
ćœ­æ° - avatar
+ 1
it's a very large number, I think it is a address of the memory but I can't explain it
2nd Aug 2017, 6:07 PM
ćœ­æ°
ćœ­æ° - avatar
+ 1
I still not understand it ,can't you say more easily
2nd Aug 2017, 6:29 PM
ćœ­æ°
ćœ­æ° - avatar
+ 1
OK 🆗 thank you so much I know it now
3rd Aug 2017, 1:23 AM
ćœ­æ°
ćœ­æ° - avatar
0
@Hatsy Rei
2nd Aug 2017, 2:22 PM
ćœ­æ°
ćœ­æ° - avatar