Home > Backend Development > C++ > body text

What does *& mean in c++

下次还敢
Release: 2024-04-28 09:47:21
Original
1106 people have browsed it

Both the & and &** operators in C are used to get addresses, but their subtle difference is that the & operator gets the address of a variable, which is stored in a pointer variable, and the pointer type points to the variable type. The &** operator gets the address of the pointer variable, stored in the pointer variable, and the pointer type points to the pointer type. Purpose: The & operator is used to get the address of a variable to be passed to a function or stored in another variable, while the &** operator is used to get the address of a pointer variable and is used to create a pointer to a pointer.

What does *& mean in c++

The & and &** operators in C

In C, The & and & operators are used to get the address of a variable, but they have a subtle difference:

& Operator:

    ## The & operator takes the address of a variable and stores that address in another variable.
  • The operator is followed by a variable name.
  • The generated address type is a pointer type, pointing to the variable type being addressed.

Example:

int num = 10;
int *ptr = # // ptr 现在指向 num 的地址,类型为 int*
Copy after login

& Operator: **

  • & The operator takes the address of a pointer and generates a pointer to the pointer variable.
  • The operator is followed by a pointer variable name.
  • The generated address type is a pointer type pointing to a pointer type.

Example:

int num = 10;
int *ptr = #
int **ptrptr = &ptr; // ptrptr 现在指向 ptr 的地址,类型为 int**
Copy after login

Difference:

    & operator takes the address of the variable, while
  • & The operator takes the address of the pointer. The
  • & operator produces a pointer type that points to a variable type, while the
  • & operator produces a pointer type that points to a pointer type.

Purpose: The

    & operator is used to get the address of a variable so that it can be passed to a function or stored in another variable.
  • & operator is used to get the address of a pointer variable and is used to create a pointer to a pointer.

The above is the detailed content of What does *& mean in c++. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
c++
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template