what is different between classes and functions? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

what is different between classes and functions?

I want to know whats the diffrent

16th May 2018, 6:48 AM
Mohammadali Dastour
Mohammadali Dastour - avatar
4 Answers
+ 2
A function is a piece of code that does something. If written correctly, it does only 1 thing. A class is the definition/description used to create an object. A class can hold multiple variables of any type and/or functions.
27th May 2018, 6:34 PM
Keri
Keri - avatar
+ 1
Example: #include <iostream> using namespace std; class Person{// Person is a class public: int name; void getName(); void setName();//This is a function }; void Person::getName(){ printf("Name of Person"); } int main() { return 0; }
16th May 2018, 7:14 AM
ThiemTD
ThiemTD - avatar
0
A function is a block of code you can use. A class is a collection of functions and variables that can access each other.
17th May 2018, 4:40 AM
Nick Farley
Nick Farley - avatar