when the name of local & global variables are the same how will u access both of them one by one?

Answer

When the name of both the variables are the same then we will call the variable (for example take it as "x"), then by default, the system will consider the local variable by this call. But if you want to call global variable then you have to use a special operator SCOPE RESOLUTION OPERATOR (::), then it will refer to the global variable

 

local variable: cout<<x;

global variable: cout<<::x;

All c++ Questions

Ask your interview questions on c

Write Your comment or Questions if you want the answers on c from c Experts
Name* :
Email Id* :
Mob no* :
Question
Or
Comment* :
 





Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---