Suppose I have a bunch of valid pointers to instances of a class A
. Can I safely and portably assume that the pointers will stay the same during the whole object lifetime? In other words, can I use a pointer to an object as a unique object ID?
A pointer is a type of variable that carries location information. In this case, the example variable will store the address of an Order object that we want to interact with. We initialize the pointer variable by using the C++ new operator to construct a new object of type Order.
A pointer is simply a variable that holds the memory address of another type or variable. By default, C# does not allow you to use pointers in your apps.
Pointer variables may point to struct or class objects.
Pointers can be used to pass of arrays and strings to functions more efficiently. Pointers save the memory. Pointers reduce the length and complexity of a program. Pointers make possible to return more than one value from the function.
Sure; I don't see why not.
A memory address is pretty much the definition of object identity (taking type out of the equation for a moment).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With