Difference between revisions of "cpp/language/operator logical"
(Created page with "{{title|Logical operators}} {{cpp/language/sidebar}} Returns a boolean value. {| class="wikitable" style="font-size:85%;" |- ! rowspan="2" | Operator name ! rowspan="2" | Keywor...") |
m (replaced || with {{!!}} in table) |
||
Line 32: | Line 32: | ||
| {{tt|<nowiki>a || b</nowiki>}} | | {{tt|<nowiki>a || b</nowiki>}} | ||
| {{yes}} | | {{yes}} | ||
− | | {{cpp|bool T::operator | + | | {{cpp|bool T::operator{{!!}} (const T2 &b) const;}} |
− | | {{cpp|bool operator | + | | {{cpp|bool operator{{!!}} (const T &a, const T2 &b);}} |
|- | |- | ||
| colspan="6" | | | colspan="6" | | ||
:'''Notes'''<br> | :'''Notes'''<br> | ||
− | * The keyword-like forms (and,or,not) and the symbol-like forms (&&,| | + | * The keyword-like forms ({{cpp|and}},{{cpp|or}},{{cpp|not}}) and the symbol-like forms ({{cpp|&&}},{{cpp|{{!!}}}},{{cpp|!}}) have exactly the same meaning everywhere they can occur |
* Operators {{cpp|and}} and {{cpp|not}} perform short-circuit evaluation when used with basic type but that is not true if overloaded ( as they behave as functions ) | * Operators {{cpp|and}} and {{cpp|not}} perform short-circuit evaluation when used with basic type but that is not true if overloaded ( as they behave as functions ) | ||
|} | |} |
Revision as of 03:10, 5 March 2012
Template:cpp/language/sidebar Returns a boolean value.
Operator name | Keyword | Syntax | Overloadable | Prototype examples (for Template:cpp) | |
---|---|---|---|---|---|
Inside class definition | Outside class definition | ||||
negation | Template:cpp | !a
|
Yes | Template:cpp | Template:cpp |
AND | Template:cpp | a && b
|
Yes | Template:cpp | Template:cpp |
inclusive OR | Template:cpp | a || b
|
Yes | Template:cpp | Template:cpp |
|
See also
Common operators | ||||||
---|---|---|---|---|---|---|
assignment | increment decrement |
arithmetic | logical | comparison | member access |
other |
a = b |
++a |
+a |
!a |
a == b |
a[...] |
function call |
a(...) | ||||||
comma | ||||||
a, b | ||||||
conditional | ||||||
a ? b : c | ||||||
Special operators | ||||||
static_cast converts one type to another related type |