Understanding how primitive data types works is easy: Everything in a computer is stored as a series of 0s and 1s, and so everything I need to store needs to be encoded as a series of 0s and 1s. For example: the real number 3.14
must be stored as a bit pattern, the negative number -1234
must be stored as a bit pattern, the character 'A'
must be stored as a bit pattern, etc. When I store one of these data in memory, I have to mark the memory location of where they're stored with a specific data type (e.g. float
for a bit pattern that represents a real number), this data type tells me how to interpret this bit pattern when I ask for it later.
But how this definition applies to something like a class, I mean when I create an object of a specific class, for example:
MyClass mc;
mc
does not store a bit pattern that needs to be interpreted in a specific way, how to make sense of considering a class to be a data type? Or is there's another definition for a data type?