

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
C++ Scope resolution operator
The scope resolution operator ( :: ) is used for several reasons. For example: If the global variable name is same as local variable name, the scope resolution operator will be used to call the global variable. It is also used to define a function outside the class and used to access the static variables of class.
Here an example of scope resolution operator in C++ language,
Example
#include <iostream> using namespace std; char a = 'm'; static int b = 50; int main() { char a = 's'; cout << "The static variable : "<< ::b; cout << "\nThe local variable : " << a; cout << "\nThe global variable : " << ::a; return 0; }
Output
Here is the output
The static variable : 50 The local variable : s The global variable : m
- Related Questions & Answers
- Scope resolution operator in C++
- PHP Scope Resolution Operator (::)
- Why does C++ need the scope resolution operator?
- What is the scope resolution operator in C#?
- Scope Resolution Operator Versus this pointer in C++?
- Scope Resolution Operator vs this pointer in C++
- Where do we use scope Resolution Operator (::) in C#?
- What is the use of scope resolution operator in C++?
- Scope Rules in C
- C++ Scope of Variables
- Scope of Variables in C++
- Scope of Variables in C#
- Avoid Scope Creep: Control Your Project Scope
- Variables, their types, and Scope in C++
- PHP Variable Scope
Advertisements