搜尋此網誌

2025年6月18日星期三

Sth abt Pointers

delve into: to try hard to find out more information about something

An automatic variable is a type of local variable that’s automatically created when a function or block is entered and destroyed when it’s exited. You’ll find this concept in languages like C, C++, and Java.

A function is a reusable block of code designed to perform a specific task. You define it once and can call it multiple times throughout your program. Functions help keep code organized, readable, and modular.

A block is a group of statements enclosed in curly braces {}. It defines a scope in many programming languages. Blocks are used in functions, loops, conditionals, and more.

So, a function contains a block, but not every block is a function. Think of a function as a named tool, and a block as the toolbox where the instructions live.

indispensable: too important to be without

The return address is a key part of how function calls work in many programming languages and computer architectures. When a function is called, the program needs to remember where to come back to after the function finishes. That’s where the return address comes in.

Last In, First Out (LIFO) is a method of organizing and accessing data where the most recently added item is the first one to be removed. It’s like stacking plates: you add to the top, and you also remove from the top.

trade-off: the act of balancing two things that are opposed to each other

A dangling pointer is a pointer that still holds the address of memory that has already been freed or deallocated. It’s like having the key to a hotel room that’s already been cleaned out and reassigned—you’ve got the key, but what’s behind the door is no longer what you expect.

nullptr is a special keyword introduced in C++11 to represent a null pointer constant in a type-safe way. Before nullptr, programmers used NULL or 0, which could lead to ambiguity --- especially in function overloads.

modular: (of machines, buildings, etc.) consisting of separate parts or units that can be joined together

The -> operator in C++ is called the member access operator for pointers. It’s a shorthand for accessing members (variables or functions) of an object through a pointer.

shorthand: a quick way of writing using special signs or abbreviations, used especially to record what somebody is saying

A void pointer (void*) in C++ is a special type of pointer that can point to any data type, but it doesn’t know what type it’s pointing to. That’s why it’s often called a generic pointer.

A smart pointer in C++ is like a regular pointer with superpowers—it automatically manages the memory it points to, helping you avoid memory leaks, dangling pointers, and other pointer-related headaches.

A shared_ptr in C++ is a type of smart pointer that allows multiple pointers to share ownership of the same dynamically allocated object. It’s part of the C++11 standard and lives in the <memory> header.

robust: strong and healthy

Microsoft Copilot

沒有留言:

發佈留言