A function or method is basically a block of statements that perform a specific task. For example, you are building an application in C++ language and in one of your program, you need to perform the same task more than once. In such case, you have 2 options:
A) Use the same set of statements every time you want to perform the task
B) Create a function/Method to perform that task, and just call it when you need to perform that task.
Using option (B) is always a good practice and a good programmer always uses functions while writing codes in C++ or any other programming language.