|
-
October 12th, 2005, 01:55 AM
#1
Local Class
why local class cannot have static member?
Regards,
Rameshkanth
BORN TO WIN
-
October 12th, 2005, 02:17 AM
#2
Re: Local Class
 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.
Can you help me with my homework assignment?, Before you post!, Use code tags, How to post!, Codeguru technical FAQs, C++ FAQ Lite, Stroustrup: C++ Style and Technique FAQ, Guru of the Week, Comeau C and C++ FAQs, Comeau C++ Templates FAQs, CUJ @ DDJ, Spam threshold
My Blogs : Learning C++ is fun | Abnegator's reflections
Open Threads : C++ Aha! Moments | Nature of work in C++?
-
October 12th, 2005, 02:33 AM
#3
Re: Local Class
 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|