Hi all,
I have an object, say its called MySuperType, which has a sub type, say it is called MySubType.
MySuperType has the following attributes:
int a;
int b;
int c;
MySubType has the following attributes: (besides inhereting a,b and c)
int d;
int e;
I was wondering if I can do something like the following:
MySuperType mytype = null;
if (sub_type) {
mytype = new MySubType ();
mytype.setD(4);
mytype.setE(5);
} else {
mytype = new MySuperType ();
}
mytype.setA(1);
mytype.setB(2);
mytype.setC(3);
sub_type is a boolean variable which will tell me which object type to create.
Can someone please comment.
Thanks,