0
我有2個不同的小部件共享10個相同的成員。然而他們也有2個階段。 每個階段都有其他人沒有的特定成員。如何正確編程
public class widget
private _id as integer
private _engravedId as string
private _stage as WidgetStage
private _wig as IWidget
end class
public interface IWidget
Calculate()
end interface
public class Twidget
implemets IWidget
private t as integer
private b as double
private d as double
end class
public class Rwidget
implemenents IWidget
private y as integer
private x as double
private b as double
end class
如果我在我的類中聲明一個Iwidget,那麼我將不得不將它強制轉換爲訪問派生類變量。有沒有更好的辦法?
如果額外的變量是私人的,即使你施放它,你將如何訪問這些變量? – Prescott 2012-08-04 01:25:04