Is there is any special meaning for raw pointer?
Is normal pointer variable and raw pointer are same?
A raw pointer is a pointer whose lifetime isn't controlled by an encapsulating object, such as a smart pointer. A raw pointer can be assigned the address of another non-pointer variable, or it can be assigned a value of nullptr .
A Smart Pointer is a wrapper class over a pointer with an operator like * and -> overloaded. The objects of the smart pointer class look like normal pointers. But, unlike Normal Pointers it can deallocate and free destroyed object memory.
References are used to refer an existing variable in another name whereas pointers are used to store address of variable. References cannot have a null value assigned but pointer can. A reference variable can be referenced by pass by value whereas a pointer can be referenced by pass by reference.
The raw pointers are exactly the same with normal pointers, they can be written like this: type * pointer_name = & variable_name; Since C++11, we have some special pointers, called "smart pointers". They are called "smart" because they know when they have to delete the used memory.
The raw pointers are exactly the same with normal pointers, they can be written like this:
type * pointer_name = & variable_name;
Since C++11, we have some special pointers, called "smart pointers". They are called "smart" because they know when they have to delete the used memory. They do it when nothing else in your program uses that block of memory. There are 3 types of smart pointers in C++11:
unique_ptr<typename> pointer_name;
weak_ptr<typename> pointer_name;
shared_ptr<typename> pointer_name;
You can read more about using these types of pointers here.
Yes, a raw pointer is a normal pointer.
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