Use of Scope resolution operator in C++

Опубликовано: 12 Сентябрь 2020
на канале: fundavibes
813
25

C++ introduces a new operator called Scope Resolution Operator.
It is Represented by :: ( double colon)

The scope resolution operator ( :: ) is used for several reasons.
1. To access the global variable
2. To define a member function outside the class.
3. To initialize or access the static variable
Use 1: To access Global Variable
C++ is also a block structured Language.
The same variable name can be used to have different meanings in different blocks.
The variable declared inside a block is said to be local to that block.
Suppose - In your Program , If the global variable name is same as local variable name then the global variable name can be accessed by using scope resolution operator.

Use 2: To define member function outside the class
Class is a collection of Data and functions.
Class specification has two parts.
1. Class declarations
2. Class function definitions.
The member functions can be defined in two ways.

1. Outside the class definition.
2. Inside the class definition.

Use 3: To access static data member in a class
In a class, If a variable is declared as static then it is known as static data member.
The type and scope of each static member variable must be defined outside the class.
It can be accessed by scope resolution operator.
General form is
Data-type class-name : : variable-name = value;

#scoperesolutionoperator
#useofscoperesolutionoperator
#howtoaccessglobalvariable
#howtodefineamemberfunctionoutsidetheclass
#howtoaccessstaticvariableinaclass
#howtodefinestaticvariableinaclass
#advantagesofscoperesolutionoperator
#classstructure
#classrepresentation
#memberfunction
#staticdatamember
#localvariable
#globalvariable

For more videos

C++ Data Types
   • C++  DATA TYPES  

C++ Input and output Operation
   • C++ Input -Output Operation  

Structure of C++ Program
   • Structure Of C++ Program  

Comparison of C and C++
   • Comparison of C and C++  

Introduction to OOP through C++
   • Introduction to  Object Oriented Prog...  

Representation of Linked List
   • Representation of Linked Lists | Subh...  

Why LInked List?
   • Why Linked list? | Subha Sree  

Insertion Operation in Single Linked List
   • Insertion operation in Single Linked ...  

Features of Java
   • Features of JAVA  

Java Introduction and Comparison with C++
   • Java Introduction and Comparison of J...  

How JVM works?
   • How JVM works?  

OOP concepts
   • Concepts of OOP  

Classes and objects
   • How to implement Classes and Objects?  

Structure of Java program
   • Structure of  JAVA program  

Function overloading in C++
   • Function Overloading in C++  


Смотрите видео Use of Scope resolution operator in C++ онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь fundavibes 12 Сентябрь 2020, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 813 раз и оно понравилось 25 людям.