Michael Will
Posts: 3
Nickname: zmichael
Registered: Dec, 2002
|
|
Re: Polymorphism & inheritance
|
Posted: Dec 4, 2002 4:42 PM
|
|
> I guess your problem is the "static" key word in the > method headers you used in the class.
> All the variables in the member class should be nonstatic > variables, meaning they are object dependent.
> And static variables are object independent. So if you > use nonstatic variable in HourlyWorker class, which is a > member of WORKER class, the variables should be > non-static, otherwise it keeps generating the same error > message.
Exactly. He has a static method in Worker, which is ok, but it cannot access nonstatic variables (getrate) then. That is the bug. So either there is only one "getrate" value for all instances, then make it static too, or there are different ones for different instances of workers, then make the method nonstatic.
Michael.
|
|