TODAY JAVA SCHOOL

In java school, programming, design, computer general knowledge, web application, software, web services, social media, digital marketing, oops, concept of programming language, oops feature, console media, graphics medium, first programming, c, c ++ , Java, PHP, SQL, MySQL, HTML, HTML_5, J_query, JavaScript, Bootstrap, Framework, images with logos, examples, shared and explained.

https://www.amazon.in/b?node=26373545031&linkCode=ll2&tag=1234567801cdb-21&linkId=3b9882431b00409b44141e0344b35a15&language=en_IN&ref_=as_li_ss_tl

Breaking

Wednesday 27 May 2020

Scope Resolution Operator In C++ | Scope Resolution Operator In C++ Programming Language | Scope Resolution Operator In C++ With Example

Scope resolution operator in C++


The scope resolution operator can be used as both unary and binary. You can use the unary scope operator if a namespace scope or global scope name is hidden by a particular declaration of an equivalent name during a block or class.The scope resolution operator to use class names or class member names.

image of Scope Resolution Operator In C++

Fig: Scope Resolution Operator In C++

Syntax:

return type class name ::

function name()

{

function of body;

}


Example:

void BCA :: display()

{

cout<<”pramod dwivedi display”;

}

 We have a global variable of name  num and a local variable of name num, to access global num , now to  use the scope resolution operator.


Program:

#include<iostream.h>

#include<conio.h>

int num=30; //global variable

void main()

int num; //local variable

cout<<”input value”;

cin>>num;

cout<<”local variable =”<<num<</n;

cout<<”global variable=”<< ::num<</n;

getch();

}


Output:

Input value 30

Local variable 30

Global variable 30


No comments:

Post a Comment