473,848 Members | 1,554 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Define "class" please

In many articles related to VB.net the word "class" is used...

How many meanings are there to this word ?

"possible to derived a class from another"

"forms are full-fledged classes"

"base class"

Nov 23 '05 #1
5 1973
A "class" really is just an object. It's the most basic thing to
Object Oriented Programming.

A class is merely a code file that defines an object - defines
properties of an object, and methods (functions or procedures) of an
object. Pretty much, what the object is and what it can do. That's
the most basic definition of a class.

As far as deriving a class from another class or deriving from a base
class, that deals with inheritance. Inheritance is another major
concept of Object Oriented Programming. Here's a quick explanation of
what a base class is. A base class is an object that can be inherited
by other classes. In other words, these sub-classes (classes that
inherit from the base class. aka child classes) have all the behavior
of the base class (sometimes called the parent class) plus the
additional behavior of the child class. So think about a Vehicle. Say
you defined a vehicle as a base class. Well a car could be a child
class as well as a boat. They can share some of the same types of
behavior - properties such as color and size, while it can have some
similar methods like Turn On and Turn Off. But then each of the child
classes would also need to have their own methods and/or properties. A
car for example would need a wheel axle, while a boat will need to have
a rudder.

And as for Windows Forms, well those are classes too in .NET. Think of
the form as an object. The form has controls on it such as text boxes
and buttons. Also any forms you add to your project are also child
classes which derive from a base class. You'll notice in the
definition of the class you'll see
Public Class Form1 Inherits System.Windows. Forms

All that means is that the object (class) Form1 shares behaviors of
System.Windows. Forms and also will have the behavior that is described
in the class itself (All the code between "Public Class" and "End

I hope that clears it up for you. You might want to not try and read
articles about VB.Net and rather get a beginnning VB.Net book. That
will not only help you understand VB .NET but also get you some insight
into Object Oriented Programming and its concepts. You might also want
to get an Obj. Oriented Prog. book too if you're having further trouble
understanding the concepts. Or even better, think about taking a class
at a local Community College for VB .NET and/or OOP. You may event
want to look for a Java class which will help with a lot with the OOP

Nov 23 '05 #2
sounds like you need to pick up a book on oo (object oriented) design.

a class is a template for an object. you create objects from classes.

class dog - can bark, has four legs

instantiate this class to make an object of this class (dog), call it

now you have an object that can bark and has four legs. You can extend this
definition to have long hair, because a collie does. now you have a derived
class called "collie" that inherits the class "dog".

a windows form is the same type of thing. when you make a new form (form1),
you automatically inherit the base "windows.forms. form" class....you can
"extend" this form you created and make a form2. Form 2 magically has all
the same labels, textboxes, and other controls that your form1 does. but
you can make it do even more.

but, dont take my word for it...i probably screwed up this explination, so
get a book on object oriented design.

hope this helps you get started!

"Rob" <rw*****@comcas t.net> wrote in message
news:mv******** ************@co mcast.com...
In many articles related to VB.net the word "class" is used...

How many meanings are there to this word ?

"possible to derived a class from another"

"forms are full-fledged classes"

"base class"

Nov 23 '05 #3
Rob wrote:
In many articles related to VB.net the word "class" is used...
How many meanings are there to this word ?
"possible to derived a class from another"
"forms are full-fledged classes"
"base class"

A class is the definition of a type. Whenever you declare a class, you
introduce a new type in your program (or library, whatever).

Class Ancestor
End Class

After having declared this new type (Ancestor) I'm able to create
instances of that type:

Dim X As New Ancestor

Now X references an instance of a class named Ancestor. The instance of
the class is called "object". The variable X is called a "reference" .

So far so good. Of course, having new types means nothing if I can't
manipulate them. That's why class types may implement behaviour (by way
of Subs, Functions and Operators) and properties (by way of err...
Properties). Besides, they may have internal members just like
variables. So let's redesign our Ancestor class to give it a few

Class Ancestor
Private mName As String

Public Sub DoThis: End Sub
Public Sub DoThat: End Sub

Public Property Name As String
Get: Return mName: End Get
Set(Value As String): mName = Value.ToUpper: End Set
End Property
End Class

Now, if I declare a variable of the Ancestor type, say, Dim X As New
Ancestor, I may manipulate the object through X.

Dim X As New Ancestor
X.Name = "Francisco"

Notice that the member mName is private, and therefore can't be seen
"from the outside". This is called "Encapsulat ion" in OOP speak, and
means that classes may hide details of their implementation.

Well, contrary to other types you see in VB.Net (Integer, Double, etc),
class-based types can be extended. This means that I can declare
another class type that extends an existing one.

Class Derived : Inherits Ancestor
Sub DoSomething: End Sub
End Class

I just created a new type, this time called Derived. I may declare
variables of type "Derived" from now on.

Dim Y As New Derived

The fact that the Derived type inherits from the Ancestor type means
that besides being the "Derived" type, this new type is also an
"Ancestor". In other words, whenever I declare a variable of type
Derived, I'm implicitly saying that it's of type Ancestor also. This
means also that all functionality implemented in the Ancestor type is
still available in the Derived type, together with the functionality
declared in the Derived type itself.

Dim Y As New Derived
Y.DoThis 'Inherited from Ancestor
Y.DoThat 'Inherited from Ancestor
Y.DoSomething 'specific of Derived
Y.Name = "Carmen" 'Inherited from Ancestor

This quality of classes is called Inheritance. It allows a great deal
of code reuse, because you create base types (ancestors) with a base
functionality and create derived types that extend or alter that base

Nevertheless, the fact that a type inherits from another, means also
that the derived type may be taken as if it was it's ancestor!

Dim Z As Ancestor
Z = New Derived 'Wow! what gives???
Z.Name = "Maria"

The previous example is perfectly legal: derived types may represent
ancestor types (but not the contrary!). Of course, since the variable Z
represents an Ancestor type, even though it is "loaded" with an
instance of a Derived type, you can only use it as if it was an

Dim Z As Ancestor = New Derived
Z.DoThis 'Ok, it's an Ancestor method
Z.DoSomething 'na-na-na... DoSomething doesn't exist in the Ancestor

This may seem like a show stoper, but actually there's more things
going on under the curtains. It turns out that a derived type may
change the behaviour of methods declared in the ancestor type. If, for
instance, our ancestor type was declared like this:

Class Ancestor
Overridable Sub PrintYourName
Console.Writeln (mName)
End Sub
End Class

Dim W As New Ancestor
W.Name = "Pedro"
W.PrintYourName ' will print "PEDRO"

No we could change the behavior of the PrintYourName method from a
derived class. More over, whenever a variable *of the ancestor type*
(but referencing an instance of the derived type) executed the
PrintYourName method, the executed code would come from the derived

Class Derived
Overrides Sub PrintYourName
Console.WriteLn (Name & " derived!")
End Sub
End Class

Dim W As Ancestor = New Derived
W.Name = "Pedro"
W.PrintYourName ' will print "PEDRO derived!"

This characteristic of classes is called Polymorphism.

Although all this may seem far-fetched, notice that you're constantly
applying these concepts in your VB.Net programs. When you declare a
form (or, actually, the framework declares one for you) you'll notice
that it's a new type extending an existing one:

Public Class Form1
Inherits System.Windows. Forms.Form
End Class

And many methods of your form are actually overrides of methods
declared in the Form class. Because of this, the framework may treat
objects of your new type (Form1 in the example) as if they were of type
Form. That's how all the magic happens. ;-)

Hope this helped.



Nov 23 '05 #4

"Rob" <rw*****@comcas t.net> wrote in message
news:mv******** ************@co mcast.com...
In many articles related to VB.net the word "class" is used...

How many meanings are there to this word ?

"possible to derived a class from another"

"forms are full-fledged classes"

"base class"

You can create (instantiate) objects from a class.
For instance:
a text box you see in the toolbox is a 'Class'
when you drag the textbox onto your form, you create an instance of the
textBox class - you have 'instantiated' it. it has identity and state.
Identity is the name you give to the textbox. Its state refers to the values
of its instance variables (the properties).
a Class is the code from which you can instantiate objects.
that's enough for now - you won't get a complete lesson over a newsgroup.
When you see the word 'Class' in the book - keep reading.
Nov 23 '05 #5

In addition to the others

A class can have shared members, than the class is for those shared members
direct a part of the program. It does not need to be instanced, those
members are a consistent part of your program.

In the mainform in VBNet is a construction that automatic instances that
mainform as a shared class in your program. This as you set in the project
properties that it is the startup class. I thought that there are 7 other
startup methods once described by Jay. With that startup form you get than a
kind of behaviour as wooster11 describes.

I hope this helps,

"Rob" <rw*****@comcas t.net> schreef in bericht
news:mv******** ************@co mcast.com...
In many articles related to VB.net the word "class" is used...

How many meanings are there to this word ?

"possible to derived a class from another"

"forms are full-fledged classes"

"base class"

Nov 23 '05 #6

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

Similar topics

by: Peter King | last post by:
if you assign multiple classes in order to keep your classes generic e.g ..classA { position.absolute; left:5 top:5 height:200 width:800 } ..classB { background-color: red} ..classC { background-color: green} <div id="div1" class="classA classB" ... but then want to dynamically assign a new class
by: Gianni Mariani | last post by:
It started out as an ugly hack and it turned out to be very easy to do but I'm concerned about wether I'm not seeing somthing so I'm asking the wise ladies and gents of clc++ as to wether they turn to stone. The problem goes like this. I have a class that uses an intrusive reference count to manage the it's life-time. This class has multiple interfaces e.g. (using Austria C++ type smart pointers)...
by: hutch | last post by:
Hi, I'm making use of this VERY useful function for a so called 'standards compliant' replacement for target="_blank": function externalLinks() { if (!document.getElementsByTagName) return; var anchors = document.getElementsByTagName("a"); for (var i=0; i<anchors.length; i++) { var anchor = anchors;
by: BobPaul | last post by:
I'm following code out of a howto book and this is really bugging me. This header file was created by VStudio 6.0 when I did a "Right Click: Add Member Function" CLine is a class I wrote (per the book's instructions) and Line.h in included in Day10Doc.cpp Here is the contents of Day10Doc.h #if !defined(AFX_DAY10DOC_H__16736853_CB29_49E7_A8ED_C912CAE666EC__INCLUDED_) #define AFX_DAY10DOC_H__16736853_CB29_49E7_A8ED_C912CAE666EC__INCLUDED_ ...
by: Yarco | last post by:
In c++ we could modify the private variable in a class use friend keyword. How could it be done in php? class YourBag { int money; friend class Thief; // friend? };
by: Sudhanshu | last post by:
I have a c code that uses "class" as the variable name in a function prototype I want to use this in c++ file How can I use it ? Any ideas Sudhanshu
by: Roedy Green | last post by:
The only browser I have encountered that supports <colgroup><col class="behold"></colgroup> to apply a CSS style to a whole column, is Microsoft Internet Explorer. I have been told it SHOULD NOT do so, since this is not part of the specification. How then to you apply styles to entire columns? Surely you don't have to write <td class="behold"on every row item.
by: Hukkky | last post by:
File : NodeList.h //---------------------------------------------------------------------- #ifndef NODELIST_H #define NODELIST_H #include <string> using std::string; template <typename T> class NodeList {
by: Luna Moon | last post by:
Here is a quote from the book: C++ Annotations, I don't understand these sentences, could anybody help me? thanks! As a side effect to this implementation it must be stressed that it is not anymore correct to declare iostream objects using standard forward declarations, like: class ostream; // now erroneous
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.