I'm having a hard time understanding the differences between functions, classes, types, and objects. Can someone please help explain them to me

Function:

A function creates an association between its input and its output.

Note that this gets a little more complicated in programming, as some functions have side effects. But in general, we're taking input and returning output based on what the input is.

Type:

A type is a set of possible values. For example, the integer type contains the set of integers. The float type contains the set of float values. The string type contains the set of strings.

There can also be a product type such as the following:

struct Point {
    int x;
    int y;
};

The Point type, of course, contains the Cartesian product of the integers and the integers.

Class:

A class is a type and a set of functions that are associated with that type. For example, the string class contains data (its contents, like "Hello World") and functions that are common to all strings (length, empty, etc).

Objects

An object is an instance of a class. Thus, if I have a class string, then string_object is an object of type string.

std::string string_object;
/r/learnprogramming Thread