Q:

What are the functions of the scope resolution operator in c++?

0

What are the functions of the scope resolution operator in c++?

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Answer:

The functions of the scope resolution operator include the following.

  • It helps in resolving the scope of various global variables.
  • It helps in associating the function with the class when it is defined outside the class.

See the below code in which using the resolution operator we are accessing the global variable,

#include <iostream>
using namespace std;
int data = 0;
int main()
{
    int data = 0;
    ::data = 1;  // set global data to 1
    data = 2;    // set local data to 2
    cout << ::data << ", " << data;
    return 0;
}

Output: 1.2

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C++ Interview Questions For Experienced

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Write a program that describes the safe way to acc... >>
<< STL Containers – What are the types of STL conta...