Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Abstract classes

Status
Not open for further replies.

petrusp

Instructor
Feb 2, 2005
18
ZA
Could someone please help me clarify the following matter?

An abstract class is a class which has to be inherited. An instance of an abstract class can never be created, but references of abstract classes can be declared.

Considering this, can an abstract class contain a constructor and can the declaration of a reference of an abstract class be seen as an instantation of an object/object reference of an abstract class?
 
can an abstract class contain a constructor

yes

can the declaration of a reference of an abstract class be seen as an instantation of an object/object reference of an abstract class?

no an abstract claas can never be instantiated, but it can be used to put an object in it from a childclass, so you would still need an instantiated object from that childclass to put it in the abstarct claas reference. So you would just make an abstract reference to put severeal different objects of a childclass in.
For example

dim c as control

can contain a form, a textbox, a combobox, ... wich all inherit from control.

so

dim c(5) as control
c(0) = form1
c(1) = textbox1
...

would work and could be usefull.

Hope that made it clearer.





Christiaan Baes
Belgium

If you want to get an answer read this FAQ faq796-2540
There's no such thing as a winnable war - Sting
 
I use abstract classes for all of my reports, letters and invoices.

The base class contains all of the code to handle threading, tracking and output, but it has a must override method that is used to actually create the out put.

Then I inherit the abstract base class into the child classes that contain the code to create the output.

Then from the presentation layer, I can track the report by a base variable of the base class type. We have a reporting app that runs 30 different reports, and this allows us to have a standardized way to interact with and to code each of them.

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top