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

static classes, nested class, public class

Would you quickly remind me the difference between, regular class,
static class, and nested class?

Thanks
Nov 2 '08 #1
3 3874
"puzzlecracker" <ir*********@gmail.comwrote in message
news:5d**********************************@n33g2000 pri.googlegroups.com...
Would you quickly remind me the difference between, regular class,
static class, and nested class?
A 'regular' class my be used to create object instances for which the class
is the type. Each instance will hold a set of fields which hold values for
that instance only. A class may also contain static members which may be
fields, properties or methods which are common across all instances of the
class. Such static members are accessed through the Type name.

A class marked as static may only contain static members and instances of a
static class cannot be created.

A nested class is a class that is defined inside another class. One
difference that a nested class has from a regular class is that it may be
private where it can only be used inside the class definining it, whereas a
regular class cannot be private.

--
Anthony Jones - MVP ASP/ASP.NET

Nov 2 '08 #2
A 'regular' class can contain any kind of members (fields, methods,
properties, events et cetera), be it static or accessible through an
instance only. A static class, however, can only contain static members and
this is especially useful when the design you choose assumes that this class
cannot or should not be instantiated, for example a set of helper functions.

A nested class is defined within the scope of its 'parent' class--it may be
private or accessible to external classes. You might want to choose to do
this if your design assumes a hierarchical relationship between the two (or
more) classes.
--
Stanimir Stoyanov
http://stoyanoff.info

"puzzlecracker" <ir*********@gmail.comwrote in message
news:5d**********************************@n33g2000 pri.googlegroups.com...
Would you quickly remind me the difference between, regular class,
static class, and nested class?

Thanks
Nov 2 '08 #3
Anthony Jones wrote:
"puzzlecracker" <ir*********@gmail.comwrote in message
news:5d**********************************@n33g2000 pri.googlegroups.com...
>Would you quickly remind me the difference between, regular class,
static class, and nested class?

A 'regular' class my be used to create object instances for which the
class is the type. Each instance will hold a set of fields which
hold values for that instance only. A class may also contain static
members which may be fields, properties or methods which are common
across all instances of the class. Such static members are accessed
through the Type name.
A class marked as static may only contain static members and
instances of a static class cannot be created.

A nested class is a class that is defined inside another class. One
difference that a nested class has from a regular class is that it
may be private where it can only be used inside the class definining
it, whereas a regular class cannot be private.
Also, being a member of the containing class, it has permission to use
private and protected members of the containing class. Static members are
of course accessible directly, and instance members can be explicitly
referenced using a reference to an object derived from the containing class.
Note that these are NOT Java inner classes, there is no implicit reference
to an instance of the containing class.

And Java uses the static keyword very differently with member classes --
Java defaults to defining an "inner class" and you use "static" to get a
normal nested class. C# always gives you a nested class.
Nov 3 '08 #4

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

Similar topics

2
by: newbiecpp | last post by:
Java can declare a static nested class. Does C++ have same thing like? class Outer { public: static class Inner { ... }; .... };
6
by: B0nj | last post by:
I've got a class in which I want to implement a property that operates like an indexer, for the various colors associated with the class. For instance, I want to be able to do 'set' operations...
8
by: Robert W. | last post by:
I've almost completed building a Model-View-Controller but have run into a snag. When an event is fired on a form control I want to automatically updated the "connnected" property in the Model. ...
2
by: Bob Day | last post by:
Using VS2003, VB.NET, MSDE... I am looking at a demo program that, to my surprise, has nested classes, such as the example below. I guess it surprised me becuase you cannot have nested subs,...
6
by: ivan.leben | last post by:
I want to write a Mesh class using half-edges. This class uses three other classes: Vertex, HalfEdge and Face. These classes should be linked properly in the process of building up the mesh by...
49
by: Ben Voigt [C++ MVP] | last post by:
I'm trying to construct a compelling example of the need for a language feature, with full support for generics, to introduce all static members and nested classes of another type into the current...
12
by: raylopez99 | last post by:
Keywords: scope resolution, passing classes between parent and child forms, parameter constructor method, normal constructor, default constructor, forward reference, sharing classes between forms....
2
by: pinki panda | last post by:
i want to knw the diff between static class and abstract class .i would appreciate if its followed by example
9
by: puzzlecracker | last post by:
It looks like static classes can have non-static member classes -- does it make sense what I just wrote? If not, let me illustrate it: public static class Foo{ private struct Bar{ } }
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.