Simple Scope Resolution Operator Example Program In C++
On this page (6sections)
About this program
This is an example program in c operator example programs. Read the concept first: Arithmetic Operators Example in C++, then study the code and output below.
Definition
The scope resolution operator is used for the Unary scope operator if a namespace scope (or) Global Scope
Scope Resolution Operator Syntax
:: identifier // for Global Scope
class-name :: identifier // for Class Scope
namespace :: identifier // for Namespace Scope
//simple syntax
:: global variable name
For more information on Scope Resolution Operator, check this link
http://www.cpp.thiyagaraaj.com/home/blog-1/scoperesolutionoperatorinc
Scope Resolution Operator Example Program
// Header Files
#include<iostream>
#include<conio.h>
#include<stdio.h>
//Main Function
using namespace std;
int a = 100; //Global variable
int main ()
{
// Local Variable Declaration
int a = 200;
cout << "Simple Scope Resolution Example Program In C++\n";
// Print Global Varibale
cout << ::a<< endl;
// Print Local Varibale
cout << a << endl;
//Main Function return Statement
return 0;
}
Sample Output
Simple Scope Resolution Example Program In C++
100
200
Related Pages
Learn the concept first, then study the code:
- C++ Programs — Browse all C++ Programs.
- Arithmetic Operators Example in C++ — Tutorial — arithmetic, relational and logical operators.
- Simple Relational Operator Example Program In C++ — More in c operator example programs.
- Simple Logical Operators Example Program In C++ — More in c operator example programs.