Results 1 to 5 of 5

Thread: Scope resolution operator C++

  1. #1
    Join Date
    Dec 2010
    Posts
    49

    Scope resolution operator C++

    I have got a desktop computer desktop computer and I have installed Turbo C in it because I have to work a lot on the C++ programming language, II just wanted to know about the inheritance being achieved in the C++ language, I have heard that it is attained with the help of some scope resolution operator , can any one please explain me if any one has any idea about programming.

  2. #2
    Join Date
    May 2009
    Posts
    527

    Re: Scope resolution operator C++

    The :: (scope resolution) operator is used to make eligible the concealed names so that you can still make use of them. You can utilize the unary scope operator if a namespace scope or global scope name is concealed by an open declaration of the similar name in a block or class. For instance :
    Code:
    int c = 0;
    	 
    	int main(void) 
    {
    	  int c = 0;
    	  ::c = 1;  // set global count to 1
    	  c = 2;    // set local count to 2
    	  return 0;
    }

  3. #3
    Join Date
    May 2009
    Posts
    529

    Re: Scope resolution operator C++

    The scope resolution operator (::) in C++ language is used to describe the previously declared member functions of a specific class. In the .cpp file you can describe the normal global functions or the member functions of the class. To discriminate between the standard functions and the class that has a member functions, programmer needs to make use of the scope resolution operator (::) in between the class name and the name of member function .

  4. #4
    Join Date
    May 2009
    Posts
    539

    Re: Scope resolution operator C++

    We take an example of Well and water Well::water() where well is a class and water() is a member function of the class well. The other makes use of the resolution operator is to solve the range of a variable when the same name for the variable is used to stand for a global variable, the variables that are declared globally , and members of multiple classes. If the resolution operator is located between the class name and the variable belonging to the class then the variable name belonging to the specific class is asked for the reference

  5. #5
    Join Date
    May 2009
    Posts
    637

    Re: Scope resolution operator C++

    #include <iostream>

    using namespace std;
    Code:
    int a = 12;   // here it is a  global variable
    
    int main() {
       int a = 13;   // here it is a local variable
       cout  << ::a << endl;
       cout  << a   << endl; 
    }
    The above example shows you the scope resolution operator , but besides that there is one more use of this operator i.e to access the members that are been declared in class scope. I think the above given example is enough to explain you about the basic functionality of a scope resolution scope resolution operator is used the name of the member that follows the operator is looked up in the scope of the class with the name that appears before the operator.

Similar Threads

  1. Which has more scope MBA, IAS or CA
    By Dharamsia in forum Education Career and Job Discussions
    Replies: 3
    Last Post: 11-04-2013, 12:25 PM
  2. what is the scope for MBA in production
    By withnikhya@gmail.com in forum Education Career and Job Discussions
    Replies: 1
    Last Post: 30-08-2012, 07:00 PM
  3. What is the future scope of php ?
    By Chinye in forum Education Career and Job Discussions
    Replies: 11
    Last Post: 29-03-2012, 02:36 PM
  4. How to use Variable scope in PHP?
    By super soaker in forum Software Development
    Replies: 4
    Last Post: 21-02-2010, 06:48 AM
  5. What does scope of variables means?
    By Jaisudha in forum Software Development
    Replies: 3
    Last Post: 24-11-2009, 02:02 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,689,602.24679 seconds with 17 queries