這不是一招,它只是簡單的類型 - 「指向Node
的指針」。
n->insertmeSort((Node *&)first);
調用insertmeSort
將鑄件first
的結果設置爲Node*&
。
void Node::insertme(Node *&to)
聲明insertme
將參考指針指向Node
作爲參數。
引用和指針是如何工作的例子:
int main() {
//Initialise `a` and `b` to 0
int a{};
int b{};
int* pointer{&a}; //Initialise `pointer` with the address of (&) `a`
int& reference{a};//Make `reference` be a reference to `a`
int*& reference_to_pointer{pointer_x};
//Now `a`, `*pointer`, `reference` and `*reference_to_pointer`
//can all be used to manipulate `a`.
//All these do the same thing (assign 10 to `a`):
a = 10;
*pointer = 10;
reference = 10;
*reference_to_pointer = 10;
//`pointer` can be rebound to point to a different thing. This can
//be done directly, or through `reference_to_pointer`.
//These lines both do the same thing (make `pointer` point to `b`):
pointer = &b;
reference_to_pointer = &b;
//Now `b`, `*pointer` and `*reference_to_pointer` can
//all be used to manipulate `b`.
//All these do the same thing (assign 20 to `b`):
b = 20;
*pointer = 20;
*reference_to_pointer = 20;
}
是的,只是一個參考類型爲指針類型。 – Healer