What's the difference between classes and functions ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What's the difference between classes and functions ?

17th Jul 2019, 3:52 PM
The unknown 321
The unknown 321 - avatar
6 Answers
+ 5
Classes are box blueprints that can make boxes called Objects that store data. Functions are a series of actions that are taken so that something meaningful can happen. Usually functions are used when there is a repeating piece of code so that repetition is avoided.
17th Jul 2019, 4:02 PM
๐Ÿ‘‘ Prometheus ๐Ÿ‡ธ๐Ÿ‡ฌ
๐Ÿ‘‘ Prometheus ๐Ÿ‡ธ๐Ÿ‡ฌ - avatar
+ 1
But what classes are used for ?
17th Jul 2019, 4:05 PM
The unknown 321
The unknown 321 - avatar
+ 1
They allow you to store certain forms of data in neat packages. For example storing an array of objects that each describe name and price is better than sorting an array of names and then an array of prices (arrays are objects themselves too!)
17th Jul 2019, 4:09 PM
๐Ÿ‘‘ Prometheus ๐Ÿ‡ธ๐Ÿ‡ฌ
๐Ÿ‘‘ Prometheus ๐Ÿ‡ธ๐Ÿ‡ฌ - avatar
+ 1
Any other things classes are used for ?
17th Jul 2019, 4:10 PM
The unknown 321
The unknown 321 - avatar
+ 1
Wdym? Classes are only blueprints! They don't serve any other purpose because the above stated purpose is the penultimate reason programming even exists.
17th Jul 2019, 4:11 PM
๐Ÿ‘‘ Prometheus ๐Ÿ‡ธ๐Ÿ‡ฌ
๐Ÿ‘‘ Prometheus ๐Ÿ‡ธ๐Ÿ‡ฌ - avatar
0
I'm confused between functions and classes.
18th Jul 2019, 7:38 PM
The unknown 321
The unknown 321 - avatar