Like Tree1Likes
  • 1 Post By Cat

if static classes can have only static members, how about nested types?

This is a discussion on if static classes can have only static members, how about nested types? within the C# Programming forums, part of the General Programming Boards category; a static class can have only static members. but it also can have tested types which would not be considered ...

  1. #1
    Registered User
    Join Date
    Sep 2011
    Posts
    71

    if static classes can have only static members, how about nested types?

    a static class can have only static members. but it also can have tested types which would not be considered static.

    proof that a class nested inside a static class is not static is that it can have non-static fields.

    so a class (or any other type) nested inside a static class would be considered an instance member of the static class?

  2. #2
    Cat
    Cat is offline
    Registered User
    Join Date
    May 2003
    Posts
    1,571
    A nested type, by itself, isn't a member of the parent class. That is, it declares what the nested class is, but it doesn't create any instance of that class.

    If you were to make a member variable that could hold an instance of the nested class, that variable would need to be static, because it's in a static class.
    itsme86 likes this.
    You ever try a pink golf ball, Wally? Why, the wind shear on a pink ball alone can take the head clean off a 90 pound midget at 300 yards.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. static class members
    By SterlingM in forum C++ Programming
    Replies: 4
    Last Post: 11-05-2009, 10:20 PM
  2. Static members in derived classes
    By Sharke in forum C++ Programming
    Replies: 3
    Last Post: 08-08-2009, 11:47 PM
  3. Static members in class
    By prongs_386 in forum C++ Programming
    Replies: 11
    Last Post: 01-03-2007, 05:36 AM
  4. Static Members...
    By BigDaddyDrew in forum C++ Programming
    Replies: 2
    Last Post: 02-11-2003, 07:46 PM
  5. static and non-static data members
    By Unregistered in forum C++ Programming
    Replies: 2
    Last Post: 06-16-2002, 10:06 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21