&
Megjelenés
![]() | ||||||||
|
Főnév
& (tsz. &s)
Programming languages
In the 20th century, following the development of formal logic, the ampersand became a commonly used logical notation for the binary operator or sentential connective AND. This usage was adopted in computing.
Many languages with syntax derived from C, including C++, Perl, and more differentiate between:
&
for bitwise AND(4 & 2)
is zero,(4 & 5)
is 4.&&
for short-circuit logical AND(4 && 2)
is true. This is different from Java, where the&&
operator is exclusively used on Boolean types.
In C, C++, and Go, a prefix &
is a unary operator denoting the address in memory of the argument, e.g. &x, &func, &a[3]
.
In C++ and PHP, unary prefix &
before a formal parameter of a function denotes pass-by-reference.