Inheritance in Visual Basic 
Author Message
 Inheritance in Visual Basic

Greetings

    Can anyone tell me in details about the Inheritance in Visual Basic?
How can I create something like the class library in Power Builder?

Thanks

Rakesh




Fri, 29 Sep 2000 03:00:00 GMT  
 Inheritance in Visual Basic

Hi,
Rakesh go to Addins option in Visual Basic 5.0 and select Class Builder
utility from there.
You can creat a project from Class Builder utility and then write the
Classes and Class Collection.

I think it will help you.

regards
Tarun

Quote:

> Greetings

>     Can anyone tell me in details about the Inheritance in Visual Basic?
> How can I create something like the class library in Power Builder?

> Thanks

> Rakesh





Fri, 29 Sep 2000 03:00:00 GMT  
 Inheritance in Visual Basic

VB doesn't support REAL inheritance!!
But with the "Implements"-keyword you can define one class and implement
it's properties and methods in another class. Check out the "Programmers
guide" for more details...


|Greetings
|
|    Can anyone tell me in details about the Inheritance in Visual Basic?
|How can I create something like the class library in Power Builder?
|
|
|Thanks
|
|Rakesh
|

|



Sat, 30 Sep 2000 03:00:00 GMT  
 Inheritance in Visual Basic

Quote:

>Hi,
>Rakesh go to Addins option in Visual Basic 5.0 and select Class Builder
>utility from there.
>You can creat a project from Class Builder utility and then write the
>Classes and Class Collection.

Even quicker, "Select All" in the class you wish to "inherit" from, and
"Paste" into the file for the new class - it does exactly the same thing!


Sat, 30 Sep 2000 03:00:00 GMT  
 Inheritance in Visual Basic

IMHO, inheritance is not inherent in VB. I mean you can not
derive classes from other classes the way you are able to
do in VC++ or Java.

One way to emulate inheritance is by means of aggregation,
in which, the derived class 'includes' the super class.

For example if you have a class Person, and would like to
derive a class Employee from it, you can do it the following way.

1. Define a class CPerson. Define it's properties and methods
to access those properties. For example a property could be
Name.

2. Then define a class CEmployee. Include the class CPerson
as a property of CEmployee class. You can define other
properties too such as HourlyRate, DateOfJoining, etc.

To make the 'aggregation' transparent to caller programs, you
will have to build some properties which GET and SET the
Person class. For example, you will have to add a property
Name to CEmployee, which ultimately gets or sets the name
property of the CPerson class.

This can go multi level. I mean, you can derive classes from
CEmployee now. For example, you can derive a class
CManager and CProgrammer from CEmployee class. Since
CEmployee includes CPerson, you do not have to include it
again.

If you want to define another class CCustomer, you can do the
same way, by including CPerson in CCustomer class, and
adding extra properties.

The hierarchy structure may look like this

                                  CPerson
                                          |
                                          |
               ------------------------------------------------
               |                                                           |
               |                                                           |
CCustomer                                            CEmployee
                                                                           |
                                                                           |
                                                   -------------------------
-----------------
                                                   |
|
                                                   |
|
                                       CManager
CProgrammer

One downside to this would be that you will have to write a lot
of code to emulate the inheritance. But then again, this is the
reason VB is called 'Object Based' and not 'Object Oriented'.

Hope this helps.

Quote:
>Greetings

>    Can anyone tell me in details about the Inheritance in Visual Basic?
>How can I create something like the class library in Power Builder?

>Thanks

>Rakesh





Sat, 30 Sep 2000 03:00:00 GMT  
 Inheritance in Visual Basic

Quote:

>One way to emulate inheritance is by means of aggregation,
>in which, the derived class 'includes' the super class.

The only problem with this being that where A is a sub-class of B, it is not
legal to say that A "is a" B.  Ho-hum.  (BTW: Not disagreeing or saying
you're wrong, just re-inforcing that it is only a v. poor emulation of
inheritance).

Quote:
> But then again, this is the
> reason VB is called 'Object Based' and not 'Object Oriented'.

But surely you are mistaken!  I am informed that VB *IS* Object Oriented by
someone who appears to carry a lot of weight in the organisation by which I
am employed (until the end of the week - YIPPEE).  They even wrote a whole
chapter in a recently published internal paper on the subject, entitled
"Visual Basic IS Object Oriented" (with capitalisation as shown).  To say
that they only just stopped short of stamping their feet and threatening to
tell mummy if anyone suggested that it wasn't OO would be unfair. (Probably
true, but unfair never-the-less).

Then again, this is the same person who asserts (in the same paper) that VB
and VC are bound to be equal in terms of performance because they share the
same compiler!!  ROTFLMO.  I haven't yet had the heart to tell the person
involved that just because two files are called the same thing (C2.EXE in
this case) doesn't mean they *are* the same thing.

I'm sure this person also thinks that VB can bring peace to all corners of
the earth and ensure redemption for all mankind on the day of judgement.

Ah well.  It takes all sorts I suppose.



Sat, 30 Sep 2000 03:00:00 GMT  
 Inheritance in Visual Basic

--
Cludio Avolio Rodrigues
IBM Global Services
Systems Specialist

http://www.c-avolio.com

Quote:

>IMHO, inheritance is not inherent in VB. I mean you can not
>derive classes from other classes the way you are able to
>do in VC++ or Java.

>One way to emulate inheritance is by means of aggregation,
>in which, the derived class 'includes' the super class.

Just a little correction. VB uses Delegation not Aggregation. Aggregation is
defined in COM but VB doens't support it.

Quote:

>For example if you have a class Person, and would like to
>derive a class Employee from it, you can do it the following way.

>1. Define a class CPerson. Define it's properties and methods
>to access those properties. For example a property could be
>Name.

>2. Then define a class CEmployee. Include the class CPerson
>as a property of CEmployee class. You can define other
>properties too such as HourlyRate, DateOfJoining, etc.

>To make the 'aggregation' transparent to caller programs, you
>will have to build some properties which GET and SET the
>Person class. For example, you will have to add a property
>Name to CEmployee, which ultimately gets or sets the name
>property of the CPerson class.

>This can go multi level. I mean, you can derive classes from
>CEmployee now. For example, you can derive a class
>CManager and CProgrammer from CEmployee class. Since
>CEmployee includes CPerson, you do not have to include it
>again.

>If you want to define another class CCustomer, you can do the
>same way, by including CPerson in CCustomer class, and
>adding extra properties.

>The hierarchy structure may look like this

>                                  CPerson
>                                          |
>                                          |
>               ------------------------------------------------
>               |
|
>               |
|
>CCustomer                                            CEmployee

|

|
>                                                   ------------------------
-
>-----------------
>                                                   |
>|
>                                                   |
>|
>                                       CManager
>CProgrammer

>One downside to this would be that you will have to write a lot
>of code to emulate the inheritance. But then again, this is the
>reason VB is called 'Object Based' and not 'Object Oriented'.

>Hope this helps.
>>Greetings

>>    Can anyone tell me in details about the Inheritance in Visual Basic?
>>How can I create something like the class library in Power Builder?

>>Thanks

>>Rakesh





Sat, 30 Sep 2000 03:00:00 GMT  
 Inheritance in Visual Basic

Quote:
>>One way to emulate inheritance is by means of aggregation,
>>in which, the derived class 'includes' the super class.
>The only problem with this being that where A is a sub-class
>of B, it is not legal to say that A "is a" B.  Ho-hum.  (BTW:
>Not disagreeing or saying you're wrong, just re-inforcing
>that it is only a v. poor emulation of inheritance).

It is not a pure inheritance at all. It is like we are bootlegging
"is-a" relationship via "has-a" relationship. But it does work.

The problem with tools which 'copy' code of superclass and
build subclass by adding properties, is that the changes in
superclass are not available to subclass automatically.
For example if you create a subclass CEmployee by
copying all the properties of CPerson. Then later if the
class CPerson changes, the changes are not automatically
carried over to CEmployee.

Of course, if the interface changes, then both types of
inheritance are affected.

Guess one has to pick and choose based on one's projects.

As far as your boss is concerned, he is making my point
by writing an article proposing that VB is OO. If it was a
universally accepted idea, he would not need an article to
suggest so. :-)

Thanks.



Sun, 01 Oct 2000 03:00:00 GMT  
 
 [ 10 post ] 

 Relevant Pages 

1. Inheritance (was Visual Basic or Delphi ? (the answer))

2. Drawing visual basic interface inheritance (UML)

3. Visual Basic Inheritance

4. do Visual Basic 6.0 and Visual Basic .NET version beta Working Both

5. Difference between Visual Basic 6 and Visual Basic.Net

6. Visual basic 4 to Visual basic 6

7. Visual Basic 3.0 to Visual Basic 6.0

8. Visual Basic 5 vs. Visual Basic 6

9. Visual basic programs - connect to a server - Visual Basic 5 Enterprice Edition

10. loading visual basic 3.0 applications in visual basic 5.0

11. Learning Basic - Visual Basic - Visual InterDev

12. Visual Basic 3.0 vs Visual Basic 4.0

 

 
Powered by phpBB® Forum Software