473,406 Members | 2,387 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Inheritance Advice

Hi All,

I'm fairly new to this OOP and have a quick question:

I have a Work Order class that has properties that are common to all my work
orders. I then have a class that inherits from this class and adds some
properties.

I want each of these classes to have a procedure called WO_Update but I'm
not sure if I can copy the code from the original class and add to it in the
inherited class (so it updates all the original classes properties and the
added ones) or if I could have a procedure with the same name that runs the
parents procedure first (I'm not sure how I would reference this). This
function just updates all the fields in the database but I have to update
some additional fields in a different table for the inherited class. Any
thoughts on how to best accomplish this would be appreciated!! Hope that
makes sense...

Cameron
Nov 20 '05 #1
2 1117
Hi Cameron,

Your query makes perfect sense :-)

Stick the following into a Form and run it. It will show you how
inheritance works.

Public Class frmMain
Private Sub frmMain_Load(....) Handles MyBase.Load
Dim BW As New WorkOrder
BW.Name = "Biggin"
BW.Update

Dim DW As New DerivedWorkOrder
DW.Name = "Derby"
DW.Update
End Sub
End Class

Public Class WorkOrder
Public Name As String
Public Overridable Sub Update
MessageBox.Show ("Updating Base (" & Name & ")")
End Sub
End Class

Public Class DerivedWorkOrder : Inherits WorkOrder
Public Overrides Sub Update
MyBase.Update
MessageBox.Show ("Updating Derived (" & Name & ")")
End Sub
End Class

As you can see in Sub Update in the DerivedWorkOrder, it calls
MyBase.Update. Using MyBase is how a class accesses the members of the class
that it was derived from.

The Overridable keyword says that the derived class may have a method with
the same name. [There is another way - Shadows - but we'll leaver that one for
now].

Regards,
Fergus
Nov 20 '05 #2
Cor
Hi Fergus,
Your samples become everytime nicer
Very simple
Cor
Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Tim Mackey | last post by:
hi folks, i'm puzzled over this one, anyone with some solid db experience might be able to enlighten me here. i'm modelling a file system in a database as follows, and i can't figure out to...
3
by: marv | last post by:
If I have abstract base classes like these: //--------- class IBase { public: virtual void Action(void) = 0; };
14
by: Mark O'Flynn | last post by:
I would like some advice regarding implementing inheritance using vb.net. I have an application written in vb6 that I am rewritting from the ground up in vb.net to take full advantage of .net,...
6
by: Pascal Polleunus | last post by:
Hi, I'm wondering if there could be problems related to inheritance in the following scenario (with PostgreSQL 7.4.1)... 1 A-table, abstract. Max 10 B-tables that inherit from A, with...
6
by: Jackson | last post by:
I've got an inheritance question and was hoping brighter minds could guide me. I am in the strange situation where some of the methods in a subclass are actually more general than methods in a...
8
by: RSH | last post by:
Hi, I am working on some general OOP constructs and I was wondering if I could get some guidance. I have an instance where I have a Base Abstract Class, and 4 Derived classes. I now need to...
6
by: Bart Simpson | last post by:
I remember reading on parashift recently, that "Composition is for code reuse, inheritance is for flexibility" see (http://www.parashift.com/c++-faq-lite/smalltalk.html#faq-30.4) This confused...
11
by: John | last post by:
Hi All, Although C# has Generics, it still does not support the generic programming paradigm. Multiple inheritance is required to support real generic programming. Here is a simple design pattern...
2
by: mmcgarry.work | last post by:
Hi, I would like to follow Stroustrup's advice of separating an object interface (abstract class) from an object implementation (concrete class), See Section 15.2.5 in Stroustrup 3rd Edition. ...
3
by: Leo Seccia | last post by:
Hello everyone, I have a c# project with a sql server database. I have a number of lookup tables in my database which I successfully managed to import into my LINQ dataclasses. eg. Table:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.