c++ is not an operator, it is a programming language (the successor to the C Programming language upon which it was based). However, if c were really an object or variable name, then ++ would be the postfix increment operator. c++ returns the value of c before incrementing c. Its counterpart, ++c, invokes the the prefix increment operator, which returns the value of c after incrementing.
++c is a convenient shorthand notation for c=c+1, which can also be written c+=1, all of which return the value of c after incrementing. c++ is also a convenient shorthand for c=c+1 or c+=1, but the return value is the original value of c, not the incremented value.
The this pointer is a special pointer that exists in every class. It is a self-referenced pointer to the current instance of the class, a pointer to the object itself. The pointer is not accessible outside the object. There is no point; if the object exists, as it must, it can be assumed you already have a pointer variable or a reference to it declared outside of the object. If not, then this instance shouldn't exist at all (it's a memory leak!).
It has many uses, but the most common is to allow the object to pass itself as a function parameter or a return value, either as an indirected reference or as a pointer, and cast as a const if required.
The this pointer can also be used to check for an incoming self-reference parameter. For instance, the object's assignment operator would have a hard time assigning its own data to itself if the object contained pointers to memory allocations. Those memory allocations need to be released before you can begin copying the incoming data. But as soon as you release that memory, you also release it from the incoming data object -- they are one and the same object after all. Now you're in trouble; your object has self-destructed, completely destroying the very data it had meant to copy -- and there's no backup!
Fortunately, prevention is better than cure. We can avoid this scenario by including a self-reference "guard" before we attempt to reassign the object's members:
CMyClass & CMyClass::operator= (const CMyClass & Incoming )
{
if( &Incoming == this ) // self-reference guard.
return( *this ); // return a reference to this -- unchanged!
// If we get this far, the incoming object is definitely a different object
// so we can safely delete this object's data and copy the incoming
// object's data to this object at this point.
return( *this ); // return a reference to this -- changed!
}
since c++ is an object oriented programming language we use object to access each data member & member functions.so that class concept is come on
calloc operator,malloc operator
The only "special" operators in C++ are those that cannot be overloaded. That is; the dot member operator (.), pointer to member operator (.*), ternary conditional operator (:?), scope resolution operator (::), sizeof() and typeof().
There is no unary plus in C, but if there were, it would have only one operand, unlike the binary plus which has two: x = a + b; /* binary plus */ x = + b; /* unary plus -- not in C*/ x = a - b; /* unary plus */ x = - b; /* unary minus */
++a (plus plus a) is pre-incrementing operator to aa=10;printf("%d",++a); /* it will print 11 as ++a increment first a by 1 then prints it */printf("%d",a++); /*it will printf 10 as it is post _ increment operator , it prints the value a first then increment it by 1 */
Selection constructs in C++if...elseswitch/caseconditional ternary operator (?:)
conditional operator , size of operator , membership operator and scope resulation operator can not be overload in c++
calloc operator,malloc operator
There is no "power" operator in C or C++. You need to the use the math library function pow().
+ is an example, one of many, of a binary operator in C or C++ a = b + c; // for usage example
There is no memory management operator in C++ -- it is an unmanaged language. You use the C++ new operator to allocate memory, and use the C++ delete operator to release previously allocated memory.
In C and in C++, the ++ operator means to increment. C++ was intended to be the next version, i.e. the incremental next step, of C, hence the use of the ++ operator.
The ++ in C++ refers to the postfix increment operator (operator++()). It's literal meaning is "the successor to C", in reference to the C language upon which the C++ language is based.
No.
type operator- ();
delete
comma (,) is an example
The only "special" operators in C++ are those that cannot be overloaded. That is; the dot member operator (.), pointer to member operator (.*), ternary conditional operator (:?), scope resolution operator (::), sizeof() and typeof().