Course Object Oriented Programming
Methods
In this class, we will see the use of C++ methods.
What is a method?
As we have seen before, methods are actions that objects in a given class can perform. Like every action performed by the computer, they are defined by a sequence of steps, by an algorithm.
Within our context, this type of action is represented by a function.
How to create a method?
It is enough to declare a function (a procedure) in the scope of the class. The easiest way is to declare and define it inside the braces that delimit the class scope. See an example:
struct classA {
void method() {
printf("Method01\n");
}
};