Scope Resolution Operator In C++
A class can have any number of member functions and each of the member functions can have any number of instructions.
A class definition should be in such a way that at a glance one should be able to know the members of a class. So we define the member functions outside the class definition. Hence make it a habit. From this point onwards we define the member functions
outside the class only.
There can be any number of classes in a program and functions with the same signature can
occur in different classes. So,:: operator resolves the scope of a function is called Scope resolution operator.
Syntax for defining a member function
return-value type <class name> :: <member function name>
body of the member function;
Example of Scope Resolution Operator in C++
Welcome to country2
Welcome to country3
Explanation of the program
Here, the:: operator is used to indicating that the functions
country()3 belong to the class MyFirst.
© 2016-2019, Codeverb.com - All Rights Reserved