----> General sintax in C++ <----
This file i find from : http://stackoverflow.com
i hope you can learn from it...
You cannot change the meaning of operators for built-in types in C++, operators can only be overloaded for user-defined types1. That is, at least one of the operands has to be of a user-defined type. As with other overloaded functions, operators can be overloaded for a certain set of parameters only once.Not all operators can be overloaded in C++. Among the operators that cannot be overloaded are the member accessors
sizeofoperator, and the only ternary operator in C++,
?:Among the operators that can be overloaded in C++ are these:
- arithmetic operators:
%=(all binary infix);
--(unary prefix and postfix)
- bit manipulation:
>>=(all binary infix)
- boolean algebra:
&&(all binary infix) and
- memory management:
- implicit conversion operators
,(all binary infix)
&(all unary prefix)
()(function call, n-ary infix)
In C++, operators are overloaded in the form of functions with special names. As with other functions, overloaded operators can generally be implemented either as a member function of their left operand's type or as non-member functions. Whether you are free to choose or bound to use either one depends on several criteria.2 A unary operator
@3, applied to an object x, is invoked either as
x.operator@(). A binary infix operator
@, applied to the objects
y, is called either as
Operators that are implemented as non-member functions are sometimes friend of their operand’s type.
1 The term “user-defined” might be slightly misleading. C++ makes the distinction between built-in types and user-defined types. To the former belong for example int, char, and double; to the latter belong all struct, class, union, and enum types, including those from the standard library, even though they are not, as such, defined by users.
2 This is covered in a later part of this FAQ.
@is not a valid operator in C++ which is why I use it as a placeholder.
4 The only ternary operator in C++ cannot be overloaded and the only n-ary operator must always be implemented as a member function.
----> Learn from wherever you are you can learn because learning is not limited to space and time (Inayah 05042012) <----