CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Local Class

  1. #1
    Join Date
    Feb 2005
    Location
    Tamilnadu, India
    Posts
    62

    Question Local Class

    why local class cannot have static member?
    Regards,
    Rameshkanth
    BORN TO WIN

  2. #2
    Join Date
    Feb 2005
    Location
    "The Capital"
    Posts
    5,306

    Thumbs up Re: Local Class

    Quote Originally Posted by ksrameshkanth
    why local class cannot have static member?
    ....because: Local classes don't have any linkage (neither internal nor external). However they can access static variables defined in the enclosing scope. You may want to have a look at this - Local Classes. Hope this helps. Regards.

  3. #3
    Join Date
    Dec 2002
    Location
    St.Louis MO, USA
    Posts
    672

    Re: Local Class

    Quote Originally Posted by MSDN
    the static keyword specifies that the variable has static duration (it is allocated when the program begins and deallocated when the program ends) and initializes it to 0 unless another value is specified.
    Actually local classes are "disposable classes", we use a local class to define a function object that is accessible only from within its scope. so its pointless to allow static variables in disposable class.
    A Person who is polite is given goodness and a person who is away from Politeness is away from Goodness.

    NAUMAAN

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured