0
class LinkedList{
private $first;
public function Merge(LinkedList $ll){
//We can't access $ll->first for merging operation as it's private inside $ll.
//We can only access $this->first not $first of $ll
}
}
有什麼可以解決這個問題?鏈表頭節點標識符/指針訪問問題
- Make $ first public?這不是一個好主意
- 實現getter方法爲$第一屬性
有人請建議我先訪問$正確的方法是什麼?
PHP不允許你訪問'$ ll-> first'? – Puppy 2012-02-07 15:46:49
@DeadMG,$ ll不等於$ this,所以我不能訪問$ ll->第一個 – 2012-02-07 15:47:28
@DeadMG:既然'first'在'private'訪問說明符下聲明,C++也不會。 – 2012-02-07 15:47:55