Scope Resolution Operator
We know the declaration of member function inside the class and now we define the member function outside the class. Structure of this outside function :
function_ruturen_type class_name :: function_name(parameter or argument) { function_statement ; } |
Here we use scope resolution operator ( :: ) for define the function outside the class.
Example :
class simple{ public : int a,b; void add(); }; void simple :: add() { cout<<”Add :”<<a+b; } |
At first, we define the function in the class then we the definition of the function written outside the class.
Written by “Shojib”
No comments:
Post a Comment