Welcome To The World Of Hacking


Learn Hacking|Teach Hacking|Learn To Secure|Learn To Code

Tuesday

C++ TUTORIAL 20: SCOPE RESOLUTION OPERATOR

#include<iostream>
using namespace std;

int x = 10; //global x

int main()
{
     int x = 15;
    {
        int p = x;
        int x = 20;

        cout<<"In the first loop \n";
        cout<<"p = "<<p<<"\n";
        cout<<"x = "<<x<<"\n";
        cout<<"::x = "<< ::x<<"\n";
    }
    cout<<"\nIn the second loop \n";
    cout<<"x = "<<x<<endl;
    cout<<"::x = "<<::x<<"\n";
    return 0;
}

OUTPUT:

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...