Every instance of a class inherits a 'this' pointer. It always points to the instance itself. Outside of the object you must use the object's variable name to refer to the object, or instantiate a pointer to the object. But from within the object's member methods you must use the 'this' pointer which is instantiated automatically as soon as the object is constructed and falls from scope when the destructor returns. Only non-static member functions have access to the 'this' pointer.
There are several uses, however the most important is when checking for self-references, particularly in the assignment operator overload. That is, any member function that accepts a reference to the same class of object should always check for self-references before attempting to mutate the instance. This is particularly important when the class "owns" memory that is dynamically allocated to it.
It is also used to return a reference to the current instance from the assignment operator and from any other operator overload or function that must return a reference to the current instance (including the addition and subtraction operators). Both uses can be seen in the following stripped-down example:
class MyObject
{
public:
// Assignment operator overload.MyObject& operator= ( const MyObject & obj ){
// Self-reference check.
if( this != &obj ){// Assignment code goes here...
}
// Return a reference to this object.
return( *this );
}
};
The 'this' pointer can also be used to pass a pointer (this) or reference (*this) to external functions that accept such arguments.
It should also be noted that when referring to an instance member from within a non-static member function, the dereferenced 'this' pointer is implied, as in:
this->[member_name]
Although this usage is never required, there may be times when it can help make your code more readable, or less ambiguous, especially when a member function must handle one or more external instances of the same class.
because u freakin can
A double pointer has two basic meanings. One is ofa pointer to a pointer, where changing the value ofdouble pointer will result in the original pointer being changed. Another is that of a two-dimentional array, such as a matrix, or a list of char* (e.g. in main when you use argv).
Pointer is a variable that stores the address of another variable. Since pointer is also akind of variable, thus pointer itself will be stored at a different memory location.
Generic pointer of type 'void *' is compatible with any (data-)pointer, but you cannot use the following operators on it: + - ++ -- += -= * -> []
*
A pointer to pointer has many uses, one of the simplest being 2D arrays (matrices). Compacting garbage collectors also often employ pointer pointers.
void pointer
Pointer is a variable that stores address of a variable . A NULL Pointer a pointer that doesn't point to anything, it is a literal zero .Some people ,notably C++ programmers, prefer to use 0 rather than NULL.
It depends on what type of data you wish to manipulate.
A Green Laser Pointer is very simple to use. In order to see the green laser from the pointer, you press the button and point it onto an opaque surface.
Pointer is a variable that stores the address of another variable . So pointer basically stores the address of another variable and size of pointer can be evaluated by using sizeof operator.
insert or delete values both side.so use double pointer