0

According to book the code give output like local =10. Global =20 ,Global+Local=30.but in this it give different values ??

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

4th Jan 2020, 6:20 AM
THE CRAZY ONE ✌️
THE CRAZY ONE ✌️ - avatar
3 Respostas
+ 2
HRITIK.DIYUNDI Line 9 should be: cout<<"\nGlobal = "<< ::num<<endl;
4th Jan 2020, 6:41 AM
Mihai Apostol
Mihai Apostol - avatar
+ 1
Mihai Apostol thank you for your help
4th Jan 2020, 6:44 AM
THE CRAZY ONE ✌️
THE CRAZY ONE ✌️ - avatar
0
cout<<"\nGlobal = "<<::num<<endl; You missed the colon infront of num in second line. In your code,first line and second line is same, you are printing the num which is local variable. To print global variable use ::num
4th Jan 2020, 6:42 AM
Geek
Geek - avatar