我只是想確保我正確地做到了這一點。我有點困惑$this->parameter,$parameter和public $parameter 這是我正在做的一個例子。我希望任何聲明爲公開的東西都可以通過$instance->parameter方法訪問。這是否意味着點訪問也會起作用?我是多餘的嗎? class Email {
public $textBody;
public $atta
我看到這樣的代碼: class Person
def initialize(name)
@name = name
end
end
我明白這一點讓我做的事情一樣person = Person.new,並在我的課像其他的方法中的別處使用@name。然後,我看到如下代碼: class Person
attr_accessor :name
end
...
不工作我有我的VB6碼兩個屬性: Public Property Get PropFileID() As Long
PropFileID = m_FileID
End Property
Public Property Get PropFileIDArray() As Long()
PropFileIDArray = m_FileIDArray
End Property
我知道該怎麼做: Class class = new Class();
class.Accessor
我不知道該怎麼做: class.Property.Accessor
class.Property.Subproperty.Accessor
class.Property.Subproperty.YetAnotherSubproperty.Accessor
例子比喻: ListBox
我很難過。我想通過包含getters和setter來優化一些代碼。這是我到目前爲止有: public class ThingHolder {
private int updateCounter=0;
private Object theThing;
public Object getThing() {
return theThing;
}
public void setTh