0 votes
35 views
in Programming Languages & Algorithms by (user.guest)

1 Answer

0 votes
by (user.guest)

The words functions and methods are used interchangeably but they are not exactly the same. A function is a piece of code called by its name, meant to do a specific function and can be called at any point, ie. if the function is declared as global, while a method though very similar to a function, is called by an object within a class.

An example of a function: A function to calculate the average of three numbers.

An example of a method: Say we have a class CARS and an object of that class Toyota, a method within the class would be one to calculate the distance car travelled, and this method can be called by the instance of that class Toyota.  Assuming the name of the method is Distance(), this will be called as Toyota.Distance()

Related questions

0 votes
1 answer 76 views
0 votes
1 answer 416 views
+2 votes
1 answer 153 views
+1 vote
1 answer 153 views
+1 vote
1 answer 62 views
0 votes
1 answer 42 views
+1 vote
1 answer 428 views
+1 vote
1 answer 57 views
+1 vote
1 answer 88 views
+1 vote
1 answer 341 views
+1 vote
1 answer 117 views
+1 vote
1 answer 328 views
0 votes
1 answer 53 views
+1 vote
1 answer 275 views
Welcome to CPENTalk.com
Solution-oriented students of computer engineering on one platform to get you that

ONE SOLUTION

...