Your attention is invited to the 11th part of an e-book on undefined behavior. This is not a textbook, as it's intended for those who are already fami

C++ programmer's guide to undefined behavior: part 11 of 11

submited by
Style Pass
2024-12-23 12:00:03

Your attention is invited to the 11th part of an e-book on undefined behavior. This is not a textbook, as it's intended for those who are already familiar with C++ programming. It's a kind of C++ programmer's guide to undefined behavior and to its most secret and exotic corners. The book was written by Dmitry Sviridkin and edited by Andrey Karpov.

What are pointers? When trying to explain them to C++ beginners, experienced developers often say that a pointer is a number that stores a memory address pointing to any object.

This is somewhat true in a very low-level programming—in assembly or machine code. But in C and C++, pointers aren't just addresses—it's far more than just a number used in some special way. Moreover, C++ (not C) has pointers that aren't memory addresses at all—specifically, pointers to class data members, and functions. However, we won't discuss them here.

A pointer is a reference data type that allows access to other objects. Unlike C++ references, pointer objects are real objects, not just bizarre aliases for existing values. Pointers relate to memory numbers and addresses only via implementation details.

Leave a Comment