answersLogoWhite

0

What is smart pointer?

User Avatar

Anonymous

17y ago
Updated: 8/16/2019

Smart pointers are C++ regular pointers except that they automatically delete the object pointed to at the appropriate time.Thus ensuring proper destruction of dynamically allocated objects.

User Avatar

Wiki User

17y ago

What else can I help you with?

Related Questions

What is thread pointer?

It is a pointer.You can pass a smart pointer from one thread to another, and the two threads are free to use their smart pointers just as they were native pointers. They can copy them, assign them, and do whatever they want with them, and the smart pointer will not get you into trouble.


Difference between pointer to constant and constant pointer?

1. pointer to a constant means you can not change what the pointer points to 2. constant pointer means you can not change the pointer.


What is triple pointer?

Example: int x; -- integer int *px= &x; -- pointer to integer int **ppx= &px; -- pointer to pointer to integer int ***pppx= &ppx; -- pointer to pointer to pointer to integer


What are pointer to pointer?

A pointer only holds an address information (location) in the memory. if a pointer holds points another pointer then it is a pointer to an other pointer. Pointer holds an address in the memory so in that address there is an other location information that shows another location.


What is smart pointer in C plus plus?

A smart pointer is a resource handle. There are three types of smart pointer: unique, shared and weak (std::unique_ptr, std::shared_ptr and std::weak_ptr, respectively). A unique pointer "owns" the resource it refers to and will destroy that resource when the pointer falls from scope. Unique pointers can be moved (transferring ownership between the pointers) but they cannot be copied. Aside from that, they behave exactly as a "naked" pointer would and incur no runtime overhead. Unique pointers are the ideal method of implementing RAII (resource acquisition is initialisation) because they provide the basic guarantee (no resource leaks). Shared and weak pointers work together to provide shared ownership. A shared pointer "owns" the shared resource while a weak pointer does not. In order to access the shared resource via a weak pointer, the weak pointer must first be converted to a shared pointer to assume temporary ownership. If the original shared pointer falls from scope during this time, the resource's lifetime is extended until the temporary shared pointer falls from scope. Weak pointers can also be used to break circular references between shared pointers. Although there is a runtime cost in using shared pointers, the cost is close to optimal compared with manual solutions using "naked" pointers, but with a much reduced maintenance burden. In multi-threaded applications, shared resources are often inevitable, but are best avoided whenever possible. However, writing lock-free code makes code difficult to maintain, thus shared pointers can often provide a convenient compromise.


What is pointer of pointer?

pointer is the variable that holds the address of another variable


Define pointer to pointer in c?

Double (**) is used to denote the double pointer. As we know the pointer stores the address of variable, Double pointer stores the address of any pointer variable. Declaration : int **ptr2Ptr;


Why is double pointer used?

Double pointer is a pointer to a pointer. So you can work with the double pointer as you work with a single one.Or you might mean 'pointer to double', eg:void clear_double (double *dp){*dp = 0;}


What is void pointer and what are its uses?

Void pointer can hold the address of any kind of pointer. But we can't operate on void pointer


C program pointers to pointers examples?

Pointer to Pointer is a double pointer, denoted by (**). Pointer stores the address of the variable and pointer to pointer stores the address of a pointer variable and syntax can be given as int **ptr2ptr;


What a cell pointer?

A cell pointer is a


What is the mouse pointer?

the move pointer