Member Functions

Reading Time: < 1 minute

A class can have functions declaration in its body. These functions are called member functions (or methods).


Example

Member functionsare declared just like regular functions.


Output
Hello!

Member functions are called (invoked) with dot notation.

We can access class properties from member functions, make any necessary calculation and so on.
For example, the printHello() member function below prints a hello message using the name property of the class.


Output
Inspire Coding

Questions

I hope the description was understandable and clear. But if you have still questions, then leave me comments below! 😉

Have a nice a day! 🙂

 


 

Follow and like us:
Click to rate this post!
[Total: 0 Average: 0]

Leave a comment

stay informed!

Subscribe to receive exclusive content and notifications