hi All

i have a question. plz answer if u can. i must b very thankful to u

question is

Why use abstract classes at all? Why not just declare a class and then make sure you never instantiate any variables of that type?

thnx in advance

>Why use abstract classes at all?

Sometimes you may want to declare a class and yet not know how to define all of the methods that belong to that class.

For example, you may want to declare a class called Writer and include in it a member method called write(). However, you don't know how to code write() because it is different for each type of Writer Device. Of course, you plan to handle this by deriving subclasses of Writer, such as Printer, Disk, Network and Console.

> Why use abstract classes at all? Why not just declare a class and
> then make sure you never instantiate any variables of that type?

...because compile time checks are far superior/efficient when compared to your code blowing up at run time. Languages which don't have the concept of Abstract classes baked in reply on hacks to achieve the same [e.g. Actionscript 3].

This question has already been answered. Start a new discussion instead.