Why do we need classes, why can’t we just use structs?
we need classes when we have to group not only variables but functions, in only one variable.
.What are methods?
methods are functions inside a class
How would you define a class?
Is basically the same for a struct with the keyword public(or private i suppose for now)inside the class
class ClassName {
public:
// variables or/ and functions(methods)
};
What is an object?
Is an instance of the class.
class Example {
public:
int x;
};
Example integer = {1}// here integer is an instance of the class Example.
Excuse me I have here a little question about a struct below?
struct Example {
int x;
};
Example integer = {1}// here integer is an instance of the struct and an object?