Byte Order in Computers

The byte is the smallest addressable unit in computer memory. When computers represent larger objects, they use multiple bytes. When storing these bytes in memory, the computer must decide in what order to store the data. Similarly, when transmitting large objects over a network, the order of transmission of multiple bytes is crucial. Connected computer systems must establish a unified way of transmitting multi-byte data to collaborate effectively.

This predetermined order for storing and transmitting multi-byte data is called byte order, also known as “endianess.” Understanding byte order is helpful for building lower-level programs and gaining a deeper understanding of computer systems.

Why we have-pointer and reference types?

… Obviously, we can refer to an object by name, but in C++ (most) objects ‘‘have identity.’’ That is, they reside at a specific address in memory, and an object can be accessed if you know its address and its type …

Bjarne Stroustrup 《The C++ Programming Language》(Fourth Edition),Chapter 7.

During our last discussion, @Lollipop9z(Invalid Link)raised this interesting question. Due to their background in learning Python programming language, they were puzzled about why features like pointers and references are provided in languages like C++. In fact, many students who have studied programming languages that include concepts of pointers and/or references still lack a thorough understanding of the reasons behind the existence of these language elements. The following code snippet illustrates this using C++ as an example.