473,401 Members | 2,127 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,401 software developers and data experts.

Inheritance

What's the difference between importing a namespaces and inheriting.
Nov 19 '05 #1
3 1702
Hi Chris,

These two things are in theory very different, although it might look
like they are sort of having a similar effect. I'm not sure that the
straightforward answer will actually help you very much because if you
haven't ever come across it before the concept is a bit complex.

Importing (adding an Imports reference to the top of a class file) is a
kind of "reference" from your file to a specific namespace. The simple way
to understand it is by example:

Without importing any namespaces into my file I might want to refer to a
class within the system.web.util namespace - to do so every time I referred
to it I would need to write:

dim XXX as system.web.util.transactions

If I add the line Imports system.web.util at the top of my file I can refer
to it simply as

dim XXX as transactions

Inheritance is totally different. Inheritance is a way of
"compartmentalising", sharing, reusing and organising chunks of code into
"objects" (classes). When I say:

Public Class MyCustomControl : inherits Webcontrol

Then I'm using inheritance - what I'm doing is saying "here is a blueprint
for a MyCustomControl - it's a type of WebControl, so it shares everything
that a webcontrol has, but with additions and differences". A really good
book on inheritance and object orientated programming is (in my opinion)
Thinking in Java by Bruce Eckel. I know java is mud - but Bruce Eckel is
very very good at helping you to "think" in object orientated ways rather
than just learn about how it works.

As always I stand ready to be corrected by someone more knowedgeable than
me - but this is my understanding of the differences between imports and
inheritance. Anyone else care to comment?

Nick

"Chris Kennedy" <ch**********@cybase.co.uk> wrote in message
news:el*************@TK2MSFTNGP12.phx.gbl...
What's the difference between importing a namespaces and inheriting.

Nov 19 '05 #2
Importing a namespace is simply a convenience which allows you to refer to
classes in that namespace without having to type the full namespace.
Example:

Imports System.Web.UI

Dim C As Control

Without the Imporst statement, every time you created a Control, you'd have
to write:

Dim C As System.Web.UI.Control

---

Inheritng is the process of assigning all the inheritable characteristics of
a class to a new class which inherits and extends the original class with
additional characteristics. Example:

Class foo
public Integer fooNum
End Class

Class bar
Inherits foo
public string barString
End Class

Class bar has 2 members: fooNum from the inherited class, and barString from
the derived class.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.

"Chris Kennedy" <ch**********@cybase.co.uk> wrote in message
news:el*************@TK2MSFTNGP12.phx.gbl...
What's the difference between importing a namespaces and inheriting.

Nov 19 '05 #3
Chris Kennedy wrote:
What's the difference between importing a namespaces and inheriting.


They're unrelated at all.

Nov 19 '05 #4

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
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...
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
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.