boolean - return type of bool function -
what return type of sort of bool function...... know return type either true of false seems complicated when have got this..
bool mypredicate (int i, int j) { return (i==j); }
this bool function used in library function called equal...... example is....
bool compare(int a, int b){ return a<b; }
so perspective here return type of these bool function.when goes true & false....
your functions mypredicate
, compare
merely thin wrappers on binary operators ==
, <
. operators functions: take number of arguments of given type, , return result of given type.
for example, imagine function bool operator==(int a, int b)
following specification:
- if
a
equalsb
returntrue
- otherwise return
false
and function bool operator<(int a, int b)
following specification:
- if
a
strictly lesserb
returntrue
- otherwise return
false
.
then write:
bool mypredicate (int i, int j) { return operator==(i, j); } bool compare(int a, int b){ return operator<(a, b); }
for convenience, programming languages allow use shorter, functionnaly equivalent syntax: i == j
, a < b
.
Comments
Post a Comment