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

  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
    Registered User
    Join Date
    May 2003
    Posts
    1,619
    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.
    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, 11: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, 06:36 AM
  4. Static Members...
    By BigDaddyDrew in forum C++ Programming
    Replies: 2
    Last Post: 02-11-2003, 08: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