GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Programming  >  C++
Go To First  |  Previous Question  |  Next Question 
 C++  |  Question 7 of 203    Print  
What is a scope resolution operator?
A scope resolution operator (::), can be used to define the member functions of a class outside the class.



  
Total Answers and Comments: 2 Last Update: December 07, 2008   
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
September 08, 2005 08:05:14   #1  
vishnu bobade        

RE: What is a scope resolution operator?
shows the scope resolution operator untangling a mess made by using
the same names for different kinds of entities

base class overridden member function using the scope resolution operator (: :):

The Fundamentals of C++ mt x y; mt const * p; ... You can use the
scope resolution operator (::) to specify the desired identifier.

 
Is this answer useful? Yes | NoAnswer is useful 0   Answer is not useful 1Overall Rating: -1    
December 07, 2008 12:24:52   #2  
burraganesh Member Since: December 2008   Contribution: 20    

RE: What is a scope resolution operator?
Scope resolution:As the name itself indicates it resolves global scope to local scope
Ex:
int a 10;
int main()
{
a 20;
cout<<::a<<endl;//prints 20
return 0;
}

Useful to convey ownership of class towards a function
Ex:
class ABC{
public:
static void fun()
{
cout<<"ABC"<<endl;
}
};
class XYZ{
public:
static void fun()
{
cout<<"XYZ"<<endl;
}
};
int main()
{
ABC::fun();
XYZ::fun();
return 0;
}

 
Is this answer useful? Yes | No

 Related Questions

A scope resolution operator (::), can be used to define the member functions of a class outside the class.  
Latest Answer : Scope resolution:As the name itself indicates,it resolves global scope to local scopeEx:int a=10;int main(){a=20;cout

  Function overloading: C++ enables several functions of the same name to be defined, as long as these functions have different sets of parameters (at least as far as their types are concerned). This 
Latest Answer : Here are some examples1) Function overloadingclass FuncOver {public:      // Constructors can also be overloaded.      FuncOver();      // Overloaded constructor.      ...

Namespaces allow us to group a set of global classes, objects and/or functions under a name. To say it somehow, they serve to split the global scope in sub-scopes known as namespaces.  The form to 
Latest Answer : Namespace is simply a name given to a global space, to form a sub-space in global space. ...

Virtual destructors: If an object (with a non-virtual destructor) is destroyed explicitly by applying the delete operator to a base-class pointer to the object, the base-class destructor function (matching 
Latest Answer : Virtual constructor is not build-in C++ feature but it doesn't mean its not used by devs in code and in conversations. There are many other things that doesn't exist in particular language yet, people find ways around to solve it (SingleTon, Virtual Constructor, ...

We can overload assignment operator as a normal function.But we can not overload assignment operator as friend function why?

What is the Basic nature of "cin" and "cout" and what concept or principle we are using on those two?
Basically "cin and cout" are INSTANCES of istream and ostream classes respectively.And the concept which is used on cin and cout is operator overloading. Extraction and Insertion operators are 

Latest Answer : New operator allows to allocate a memory from the heap, so a new instance of a class is created but operator New is used to overload the (new) operator just like overloading of other operators. Additionally: The term "operator new" is ...
Read Answers (5) | Asked by : suman

Latest Answer : Inspite of repeated requests by some (few) sensible people to everybody to read the question properly before responding, nobody listens.For doreen, the question does not ask you to explain deep copy and shallow copy mechanism neither does is asks how ...
Read Answers (3) | Asked by : suji

Latest Answer : When the operator operates on the user defined data type or operands behaves same as it operates on inbuilt data type that mechanism is known as operator overloading. The operator that performs the specific task on inbuilt data type  performs similar ...
Read Answers (6) | Asked by : santoshMudholam

Class X{X(){}X(X &obj){} // supose '=' operator is also overloaded for this class. I am not writing code for that }main(){X a;X b = a;X c(&a);X d;d = a;}What is the difference between a, b, c, d objects ?


 Sponsored Links

 
Related Articles

Concepts of Object-Oriented Programming

Object Oriented JavaScript In this chapter you ll learn about OOP Object Oriented Programming and how it relates to JavaScript As an ASP NET developer you probably have some experience working with objects and you may even be familiar with concepts such as inheritance However unless you re already a
 

C++ Dereference Operator

C Dereference Operator In this C tutorial you will learn how to access the value of variables pointed by the pointer variables using pointer concept discussed in detail mosgoogle center It is possible to access the value of variables pointed by the pointer variables using pointer This is performed
 

C++ Operator Overloading Part II

C Operator Overloading Part II Operator overloading is a very important aspect of object oriented programming Binary operators can be overloaded in a similar manner as unary operators In this C tutorial you will learn about Binary Operating Overloading explained along with syntax and example mosgoog
 

sizeof Operator

What is sizeof operator? sizeof will return the number of bytes reserved for a variable or data type. The sizeof operator is a compile-time operator that returns an integer value. In other words since sizeof is a compile time operator, when used in a expression, it does not get compiled into executa
 

Modulus Operator

What is the functionality and restrictions of Modulus Operator? When a division is performed, the remainder of the operation is given by modulus operator. The modulus operator is denoted in c by symbol %. For instance we have two integer values x and y, the operation x % y called as x modulus y give
 

Operator, Operand and Expression in C

Operator, Operand, and Expression in are symbols which take one or more operands or expressions and perform arithmetic or logical computations. Types of operators available in C are as follows: Arithmetic Assignment Logical/relational Bitwise These have operators under each
 

Prefix and Postfix Operator

How does the prefix and postfix operator on expression? The operators present in prefix and postfix are prefix increment operator denoted by ++ prefix decrement operator denoted by -- postfix increment operator postfix decrement operator The difference between the two is that i
 

SQL Programming

SQL Programming Overview Anybody who has done something for a long time has probably wanted to change how things work at some point or another. A worker at a mill might have found a more efficient way of cutting logs, or a mathematics teacher might have had a hand in changing a school&rsquo;s al
 

The Interview Snafu

How to turn someone else&rsquo;s mistake to your advantage Your dream job is about to become reality. A recruiter gave you the heads up about the perfect position at Humungous Conglomerate, Inc. You went through five interviews as well as a battery of psychological tests mandated by their HR de
 

Winning a Job Interview with a Winning Resume

Does your resume unlock your potential, take your skills to the highest level and win you the interview and the job you want now? The job market today is highly competitive and even if you think you have what it takes to get an interview you won&rsquo;t get over the line without a polished, prof
 

About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape