setting variable values of inherited classes
Posted on 2007-10-18
suppose i have three classes
inside base clase i have two variable say int a and int b
subclass extends base
and inside the driver i have
subclass c=new subclass();
How would i write such that when i instantiate the subclass the varaibles a and b both get set to 1.
I dont' want it such that i have in the constructor of subclass becuase if i extend base to another subclass and instatiate it, i want a and b to be set to 1 again.
So basically i want it such that when the subclass constructor is called, the base's constructor also get called ( since i could have a=b=1 inside that) or somthing to that effect