answersLogoWhite

0

Are pointers inherited

Updated: 8/17/2019
User Avatar

Wiki User

14y ago

Best Answer

All elements of a class are inherited, including pointers. This includes methods such as constructors and destructors that manipulate the pointers. However, the question seems related to copying, instead of to inheritance... If you do not provide a copy constructor, the compiler will provide one, but that code will only copy the pointers - unless the pointers are some kind of smart pointer class, it will not copy the objects to which they point. This results in two pointers referring to one object. The danger is in what happens when one pointer is deleted, or in what happens when one pointer's object is modified. You have to decide how to handle mutability and ownership, the latter including who gets to execute the destructor or delete sequence for the pointer? One solution is reference pointers using smart pointer technology. The pointer/object itself has a reference count which is incremented each time an address of the object is taken, such as in copying a pointer. The reference count is decremented each time a pointer is deleted and, when it reaches zero, the object itself is deleted. You can also decide if executing a mutating operation results in a second copy of the object being made, or if you can tolerate having another pointer refer to an object that has changed. These techniques can balance cost of operation against protection against memory corruption, but they do come with their own cost for design, implementation, and testing.

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Are pointers inherited
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What are void pointers?

They are pointers without type


What are the background pointers in java?

Java does not support pointers.


Where the pointers are used?

POINTERS ARE USED TO STORE ADDRESS


Pointers are replaced by what in java?

Nothing. Java does not have a concept that is equivalent to Pointers.


How do you get score 6?

3 two-pointers or 2 three-pointers


Can labs be trained as pointers?

Yes, some labs are trained as pointers, and some as retrievers.


If your dog is a pointers and shedding a lot is this normal?

Pointers shed like normal dogs


Can you use pointers in java?

Java does not support Pointers and hence you cannot use it in Java.


How many three-pointers did LeBron James make?

he made about 130,000 three pointers


Why laser mouse are used?

Because the laser pointers are much easier to use than the ball pointers. The ball pointers are often difficult to move around while the laser pointers can move in any direction without "getting stuck"


What are restricted pointers in C99?

Using this you specify that two pointers can't point on the same address


How pointers are used in java?

They aren't. Java uses the (safer) idea of references instead of pointers.