What is the point of an abstract class?
ok lets say there was a subclass that inhereited another subclass...like a class Person, a class Student, and a class GraduateStudent; why would i want to make the class person abstract and have a abstract void display(); in it if i want to override that method in the subclasses lower on the inheritance tree? Wouldn't it do the same thing to just make a normal class Person and just not have a void display...and the other 2 over ride it anyways so i seriously dont see what the point of abstract classes are
> ok lets say there was a subclass that inhereited
> another subclass...like a class Person, a class
> Student, and a class GraduateStudent; why would i
> want to make the class person abstract and have a
> abstract void display();
Because all Persons are required to be able to display(), but there's no reasonable common default behavior for display() that you can put in the base class.
Abstract methods say, "Everything of this type must be able to do this, but it's up to the individual implementations to figure out *how* to do it."
> in it if i want to override
> that method in the subclasses lower on the
> inheritance tree? Wouldn't it do the same thing to
> just make a normal class Person and just not have a
> void display..
Then you couldn't do this: Person p = getAPersonThatMightBeAStudentOrWhateverWeDoNotKnowWhat();
p.display();
or this:
void doPersonStuff(Person p) {
p.display();
}
...
Person s1 = new Student();
Student s2 = new Student();
Person t1 = new Teacher();
Teacher t2 = new Teacher();
doPersonStuff(s1);
doPersonStuff(s2);
doPersonStuff(t1);
doPersonStuf(t2);
>.and the other 2 over ride it anyways
> so i seriously dont see what the point of abstract
> classes are
I hope you do now.
Message was edited by:
jverd
jverda at 2007-7-28 17:46:26 >

> ooo thanks jverd that cleared up a whole lot for me;
> im glad some ppl here actually help by explaining
> things
Perhaps you actually try reading links that people post for your benefit instead of implying that people aren't helping you just because they aren't spoon-feeding you.
~
> ooo thanks jverd that cleared up a whole lot for me;
> im glad some ppl here actually help by explaining
> things
You're quite welcome. However, yawmark was at least as helpful as I was. If you're going to learn anything at all about software development, you're going to have to do a lot of reading, thinking, and playing around. Being sarcastic to someone who provided you with a link to useful information will only hurt your chances of getting help here in the future.
jverda at 2007-7-28 17:46:26 >

> umm i do read the links people post but it is a lot
> easier to learn when people explain it like he did
You got lucky.
In general, you can't rely on people reading your mind to know what specifically you're having trouble with.
First read the existing literature--textbooks, white papers, web pages, etc. Then, if something is still not clear, ask specific questions here, and include relevant information about what you've looked into so far and how it fell short for you.
jverda at 2007-7-28 17:46:26 >
