+ 3
what is different between classes and functions?
I want to know whats the diffrent
5 Réponses
+ 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.
+ 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;
}
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.