answersLogoWhite

0

The main weakness is that the onus is primarily upon the programmer to ensure pointers are not misused, that any memory allocated to a pointer is released as soon as that memory is no longer required, and that pointers are nullified when not in use. There is no automatic garbage collection other than when a thread terminates, at which point all consumed memory is returned back to the system, however its never a good idea to rely on this. Programs with a long life-cycle must be specifically written to clean up resources behind themselves as they go, but the same should apply to any program, regardless of how trivial. It costs nothing and failure to do so is not only lazy, the consequences could easily be dire. If the program were part of an autopilot system, for instance, the consequences wouldn't bear thinking about. For this reason alone, C++ programmers are actively encouraged to use references wherever possible (because they are much easier to use and they clean up after themselves automatically), and to only use pointers when it is absolutely necessary.

User Avatar

Wiki User

11y ago

What else can I help you with?

Related Questions

Call by reference using pointer in c plus plus?

Example: void foo( MyClass& object ){} // function with call by reference signature MyClass* p = new MyClass(); // instantiate a pointer to MyClass foo( *p ); // call by reference using the pointer


What is Dazzling Pointer in c plus plus?

The pointer that points to a block of memory that does not exist is called a dazzling pointer or wild pointer


What is 'this' pointer in c plus plus?

Address of the current object.


Find the greater no between two nos using pointer in c plus plus programming?

if (*&a > *&b) *&max = *&a; else *&max = *&b;


What is null object in c plus plus?

a pointer that is not pointing to anything


What is an address in C plus plus programming?

An address in C or C++ is the location in memory of an object or function. An address is the contents of a pointer, as opposed to the contents of the memory location pointed to by the pointer.


Which function is used to determine the position of the put pointer in a file in c plus plus?

The function ftell returns the position of the file pointer for a file.


What does multiplying a pointer by 5 in C plus plus mean How does it change the pointer's value?

Multiplication is yet another thing, what you should never do with pointers.


What is step involve is using data file in c plus plus programming?

Declaration of file pointer opening of file in desired mode. performing the desired operation. closing the file


Coding in c plus plus to swap two nos using pointer?

void swap (int &pa, int &pb) { *pa ^= *pb; *pb ^= *pa; *pa ^= *pb; }


Do you have pointer concept in c plus plus language?

Yes. All string variables are pointers as are other arrays.


Is type checking on pointer variables stronger in assembly language or in c plus plus?

C++ imposes far greater restrictions on pointer typing than assembly language. There is only a single type of pointer in assembly, which is only "typed" in any sense when dereferenced, and even then only by size. C++ pointer typing takes into account not only the size of the type of the referent, but a number of other factors, such as its relationship to other types in the class hierarchy. The only way to disable these safety checks is to explicitly break the type system using reinterpret_cast.