Scope resolution operator in C++
Scope resolution operator (::) in C++ programming language is used to define a function outside a class or when we want to use a global variable but also has a local variable with the same name.
// cpp program on scope resolution bY Amit rajpurohit
http://codevidyalay.blogspot.com
#include<iostream>
using namespace std;
int a=120;
int main()
{
int a=89;
cout<<a<<endl;
cout<<::a;
return 0;
}
//INPUT/OUTPUT:-
89
120
Related Posts:
Rethrowing an Exception in C++
Rethrowing an Exception in C++
-> A handler may decide to rethrow the exception caught without processing it. In such situations, we may simply invoke throw without any arguments as shown below:
thro… Read More
Exception Handling in C++
Exception Handling in C++
-> We often come across some peculiar problems other than logic or syntax error. They are known as exceptions.
-> Exceptions are run time anomalies(errors) or unusual conditions that A progr… Read More
Exception objects in C++
Exception objects
The exception object is available only in catch block. You cannot use the exception object outside the catch block. Following steps happen when you throw an exception and catch:
try
{
MyException … Read More
Exception specification in C++
Exception specification
-> Older code may contain dynamic exception specifications. They are now deprecated in C++, but still supported. A dynamic exception specification follows the declaration of a function, appending … Read More
Catch All Exceptions in C++
Catch All Exceptions in C++
-> In some situations, we may not be able to anticipate types of exceptions and therefore may not be able to design independent catch handlers to catch them. In such circumstances, we can forc… Read More