0

What the difference between functions and classes?

2nd Sep 2016, 5:30 PM
Дима
Дима - avatar
2 Answers
+ 2
Think of a class as a collection of attributes. Which attributes is completely up to you. Height, width, color price, score, units... Basically, the attributes are the input data you are interested in. A function is a method to manipulate input. Multiply units x price, or height x width, ask a question quiz and check the user's input, change the color. Or print the input to a file. These are all done in functions.
1st May 2018, 10:00 PM
Johannes
Johannes - avatar
0
Long story short, class is a special kind of namespace that allows you to instantiate objects with state. Function doesn't have state, it's merely a subprogram you may call.
3rd Sep 2016, 5:16 PM
trueneu
trueneu - avatar