C How to Program (8th Edition)
C How to Program (8th Edition)
8th Edition
ISBN: 9780133976892
Author: Paul J. Deitel, Harvey Deitel
Publisher: PEARSON
bartleby

Videos

Textbook Question
Book Icon
Chapter 17, Problem 17.3E

(Scope Resolution Operator) What’s the purpose of the scope resolution operator?

Expert Solution & Answer
Check Mark
Program Plan Intro

To write the purpose of the scope resolution operator.

Explanation of Solution

The scope resolution operator is mainly used in C++ and it is denoted by double colon (: :).

Suppose in a program, there are two variables one local variable and another global variable with the same name, now if there is a need to access the global variables, scope resolution operator (: :) operator will be used. Thus it is used in order to differentiate the member functions of the class and the normal functions of the class.

The main purpose of the scope resolution operator is to identify and specify the context of an identifier. It defines the already declared member in .h extension or .cpp header files of the particular class.

Example program to describe the purpose of Scope Resolution Operator (: :)

#include<iostream>
usingnamespacestd;

/*initialize a global variable*/
int a=10;
intmain()
{
/*initialize the local variable with the same name*/
int a=15;

/*print the global variable using scope resolution operator*/
cout<<"The global variable is: "<<::a<<endl;

/*print the local variable*/
cout<<"The local variable is: "<<a<<endl;

return0;
}

Output:

The global variable is: 10

The local variable is: 15

Want to see more full solutions like this?

Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
Students have asked these similar questions
what do you mean by main() function ?
-- Implement Logical disjunction (OR) using case expressions -- NOTE feel free to change the function declaration -- (pattern match on the arguments), just don't change -- the type decleration -- NOTE^2 You are NOT ALLOWED to use ||   please use elm
In a void function, how would you utilise a return statement?

Additional Engineering Textbook Solutions

Find more solutions based on key concepts
An object is a(n) ________. a. blueprint b. primitive data type c. variable d. instance of a class

Starting Out with Java: From Control Structures through Objects (6th Edition)

A diesel car gradually speeds up so that for the first 10 s its acceleration is given by dvdt=(0.12)t2+(0.6)t(f...

Differential Equations: Computing and Modeling (5th Edition), Edwards, Penney & Calvis

The ____________ is always transparent.

Web Development and Design Foundations with HTML5 (9th Edition) (What's New in Computer Science)

What is a source program?

Absolute Java (6th Edition)

Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Python - bracket parenthesis and braces; Author: MicroNG;https://www.youtube.com/watch?v=X5b7CtABvrk;License: Standard Youtube License