473,411 Members | 1,937 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,411 software developers and data experts.

vb.net and OOP (inheritance)


--
hello

If I inherit an object say Car() with my new class SportsCar(). Does vb.net
creates space in memory for the object SportsCar() and associated space for
Car().

So in effect you are creating space for 2 Objects with all its
properties/methods.

If you only ever use say half the inherited class -methods/properties, are
you actually being inefficient with memory space. With the trade off being a
more OOP design....

Is the use of Inheritance a possible overhead with system space. As in the
case above.

thanks
Nov 21 '05 #1
4 1121
John,

The only advice I can give you at the moment is, don't worry about this at
the moment. When you are a little bit further you learn what objects are
created and how. Now it will be only confusing and makes that you don't go
in the right direction.

However to tell something. There are as much objects created on the managed
heap as often that you tell.

Private(or whatever) John as New Andrew.

Private(or whatever) John as Andrew, creates only an empty place to set the
reference (address) to the next John you create from Andrew

When you look at the control classes , you will see that they inherrit every
time up with in the top Object.

I hope this helps?

Cor

"john andrew" <jo********@discussions.microsoft.com>

--
hello

If I inherit an object say Car() with my new class SportsCar(). Does
vb.net
creates space in memory for the object SportsCar() and associated space
for
Car().

So in effect you are creating space for 2 Objects with all its
properties/methods.

If you only ever use say half the inherited class -methods/properties, are
you actually being inefficient with memory space. With the trade off being
a
more OOP design....

Is the use of Inheritance a possible overhead with system space. As in the
case above.

thanks

Nov 21 '05 #2
Hi

Well I can do a fair bit with .Net already eg build classes, use controls
similiar to VB6...not everthing though but I take your point. VB.net isnt
that daunting since I have C/Java background but it will take time to be
effective in.

"Cor Ligthert" wrote:
John,

The only advice I can give you at the moment is, don't worry about this at
the moment. When you are a little bit further you learn what objects are
created and how. Now it will be only confusing and makes that you don't go
in the right direction.

However to tell something. There are as much objects created on the managed
heap as often that you tell.

Private(or whatever) John as New Andrew.

Private(or whatever) John as Andrew, creates only an empty place to set the
reference (address) to the next John you create from Andrew

When you look at the control classes , you will see that they inherrit every
time up with in the top Object.

I hope this helps?

Cor

"john andrew" <jo********@discussions.microsoft.com>

--
hello

If I inherit an object say Car() with my new class SportsCar(). Does
vb.net
creates space in memory for the object SportsCar() and associated space
for
Car().

So in effect you are creating space for 2 Objects with all its
properties/methods.

If you only ever use say half the inherited class -methods/properties, are
you actually being inefficient with memory space. With the trade off being
a
more OOP design....

Is the use of Inheritance a possible overhead with system space. As in the
case above.

thanks


Nov 21 '05 #3
A common misconception for people new to oop is that the code in a class
takes up space in the memory on a per-instance basis. This is not correct.

When a class is instantiated a structure containing its internal fields and
a list of adresses for it's virtual or overridable methods is created. If a
class has say one integer field and no virtual methods the class will occupy
about four bytes of heap space even if the methods of the class require a
million lines of code to manipulate that integer. Each instance of the class
shares the physical bytes of code in memory with all the others and the
instance of the *data* for each class is referenced through the "Me"
reference ("this" in C#)

A rough example will be that Class A has 1024 bytes of code for it's methods
plus say 100 bytes for its fields, virtual method table and Me reference.
The code for A is already loaded because its program, not data but you can
consider that it takes 1124 bytes of physical memory for one instance. Two
instances however are 1224 bytes and three instances are 1324 bytes.

I hope this explanation answers your question.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"john andrew" <jo********@discussions.microsoft.com> wrote in message
news:5F**********************************@microsof t.com...

--
hello

If I inherit an object say Car() with my new class SportsCar(). Does vb.net creates space in memory for the object SportsCar() and associated space for Car().

So in effect you are creating space for 2 Objects with all its
properties/methods.

If you only ever use say half the inherited class -methods/properties, are
you actually being inefficient with memory space. With the trade off being a more OOP design....

Is the use of Inheritance a possible overhead with system space. As in the
case above.

thanks

Nov 21 '05 #4
Get you any simple answer. Think why Microsoft support fill OO in VS.NET.

chanmm

"john andrew" <jo********@discussions.microsoft.com> wrote in message
news:5F**********************************@microsof t.com...

--
hello

If I inherit an object say Car() with my new class SportsCar(). Does
vb.net
creates space in memory for the object SportsCar() and associated space
for
Car().

So in effect you are creating space for 2 Objects with all its
properties/methods.

If you only ever use say half the inherited class -methods/properties, are
you actually being inefficient with memory space. With the trade off being
a
more OOP design....

Is the use of Inheritance a possible overhead with system space. As in the
case above.

thanks

Nov 21 '05 #5

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

Similar topics

2
by: AIM | last post by:
Error in msvc in building inheritance.obj to build hello.pyd Hello, I am trying to build the boost 1.31.0 sample extension hello.cpp. I can not compile the file inheritance.cpp because the two...
2
by: Graham Banks | last post by:
Does using multiple inheritance introduce any more performance overhead than single inheritance?
4
by: JKop | last post by:
I'm starting to think that whenever you derive one class from another, that you should use virtual inheritance *all* the time, unless you have an explicit reason not to. I'm even thinking that...
5
by: Morgan Cheng | last post by:
It seems no pattern defined by GoF takes advantage of multiple inheritance. I am wondering if there is a situation where multiple inheritance is a necessary solution. When coding in C++, should...
10
by: davidrubin | last post by:
Structural inheritance (inheriting implementation) is equivalent to composition in that a particular method must either call 'Base::foo' or invoke 'base.foo'. Apparantly, The Literature tells us to...
14
by: Steve Jorgensen | last post by:
Recently, I tried and did a poor job explaining an idea I've had for handling a particular case of implementation inheritance that would be easy and obvious in a fully OOP language, but is not at...
22
by: Matthew Louden | last post by:
I want to know why C# doesnt support multiple inheritance? But why we can inherit multiple interfaces instead? I know this is the rule, but I dont understand why. Can anyone give me some concrete...
45
by: Ben Blank | last post by:
I'm writing a family of classes which all inherit most of their methods and code (including constructors) from a single base class. When attempting to instance one of the derived classes using...
60
by: Shawnk | last post by:
Some Sr. colleges and I have had an on going discussion relative to when and if C# will ever support 'true' multiple inheritance. Relevant to this, I wanted to query the C# community (the...
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...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...

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.