answersLogoWhite

0

Can you overload object pointers

Updated: 12/15/2022
User Avatar

Wiki User

15y ago

Best Answer

Overloading refers to defining multiple functions of the same name with different numbers/types of parameters. So no, you cannot overload a pointer.

User Avatar

Wiki User

15y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Can you overload object pointers
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is pointer to an object in c plus plus?

A pointer is simply a variable that stores a memory address. Thus a pointer to an object is simply a variable that stores the memory address of an object. Since pointers are variables, they require memory of their own. Pointers may also be constant, which simply means you cannot change what they point to. Pointers can also be dereferenced to provide indirect access to the memory they point to -- hence they are known as pointers. However, unlike C, pointers are not the same as references. In C++, a reference is simply an alias for a memory address and requires no storage of its own.


What are the pointer?

A pointer is a memory address stored in memory. Conceptually, it "points" to another piece of data. Pointers are used to establish dynamic data structures. In object-oriented programming, object references are implemented as pointers.


What is smart pointer?

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.


Are pointers inherited?

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.


In C you use the concept of pointers whereas there are no pointers used in JAVA why?

Pointers in C are generally the thing that gives learners the most trouble. When C code is not written correctly with respect to pointer use, the resulting bugs can often be very difficult to find and correct. On the other hand, pointers are absolutely necessary in some cases.The designers of Java wanted to make programming easier and hence avoided adding pointers to the language. Java does have object references which accomplish much of what pointers accomplish albeit in a safer way.


What are the advantages of pointers in a program?

A pointer is simply a variable that stores a memory address and that allows that memory to be dereferenced. Unlike a reference, which must always refer to the object assigned to it, a pointer can refer to any object of the pointer's type, including null. A null pointer is simply a pointer that does not refer to any object. In languages that do not support pass by reference (such as C), pointers must be used to pass objects to functions. The pointer is passed by value, but the value is a memory address, which is the same as passing the object at that address. In languages that do support references (such as C++), references are useful when you need to guarantee an object exists because a reference can never be null. However, when passing an object to a function as an optional parameter, you must use a pointer because pointers can be null. Programmers must test pointers to ensure they are non-null before attempting to dereference them. References do not need to be tested; if a reference exists, it must refer to an object in memory.


How is a bitwise copy made in c plus plus?

A bitwise copy is what you automatically get when you do not provide a copy constructor. The compiler simply provides code that copies the object without regard to the type of the members. This is dangerous if any of the members happen to be pointers, because then you have two pointers to the same object and, if you delete one, you wind up having the other pointing to an object that has been deleted.


When the destructor may be invoked in c?

C is not an object-oriented language -- there are no destructors. In C++, however, an object's destructor is invoked automatically when the object falls from scope. The destructor can also be invoked by manually deleting a raw pointer to the object (or one of its base classes), however you should only ever use the delete operator if the object was instantiated with the new operator, and only after all references or pointers to the object have fallen from scope. The safest way to manage raw pointers is to use a resource handle or smart pointer.


What is a bit copy?

A bit copy of an object is an exact, bit-by-bit, copy of that object. The default copy constructor generated by the compiler makes a bit copy. This is potentially a problem if the object contains pointers to other objects... A bit copy of a pointer copies the pointer, but not its data. This means that you have two pointers pointing at the same object in memory. If you delete one of them, the other becomes invalid, and this can (usually does) cause corruption. If an object contains a pointer, the object's copy constructor should provide for proper allocation and copying of any pointed to objects within that object.


When was Overload - Overload album - created?

Overload - Overload album - was created in 2006.


What is an array of pointers to pointers?

A pointer is a variable that stores value of address of a variable. Since a pointer itself is a variable, it is allocated a memory location.Pointer to pointer means a pointer which points to the address of a pointer. In other words a pointer to a pointer has the address of the address of a variable.We can have pointers to int, and pointers to char, and pointers to any structures we've defined, and in fact pointers to any type in C, it shouldn't come as too much of a surprise that we can have pointers to other pointers. If we're used to thinking about simple pointers, and to keeping clear in our minds the distinction between the pointer itself and what it points to, we should be able to think about pointers to pointers, too, although we'll now have to distinguish between the pointer, what it points to, and what the pointer that it points to points.


What is dangling pointer reference in c plus plus?

A dangling pointer (we also use the terms stray pointer and wild pointer) is created whenever we call delete on a pointer and then try to use the pointer without reassigning it.We can also create dangling pointers inadvertently by calling a rogue function that returns a pointer to an object that is local to the function we are calling. The object will fall from scope when the function returns so the pointer is left dangling.Note that there is no such thing as a dangling pointer reference. Pointers and references are not the same. A reference is merely an alias to an object -- it consumes no memory beyond the object it refers to. Whereas a pointer is a variable that may contain the address of an object, but it requires additional memory to do so (4 bytes on 32-bit architecture). Pointers may be NULL, references can never be NULL. Pointers to valid objects require indirection, references do not. References are the preferred method of accessing an object's members, not least because they are easier to work with.