|
-
Mar 31st, 2003, 12:47 PM
#1
Thread Starter
Lively Member
static functions
alright so i understand how a static variable works..but i dont understand how a static function works..i cant find any clear info on it..does anyone have a nice smart way of explaining it? 
thanks
-
Mar 31st, 2003, 02:03 PM
#2
transcendental analytic
static functions like static variables have class scope but are independent of objects, so declaring a function static within a class disables its access to the object variables, which is of course good if you don't need them (as it doesn't need an object and you call the function with classname::functionname).
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Mar 31st, 2003, 04:19 PM
#3
Frenzied Member
Or.
Volatile functions are 'created' on the fly. The arguments are pushed on the stack, the function's variables are initialized, the function is executed, return values are pushed onto the stack and all of the functions variables are destroyed, along with any associated stack space. Memory efficient.
If a function calls another function, then all variables, the local stack & stack pointers, register contents are all pushed onto the stack, then destroyed. This invokes execessive stack use for nested functions that are called from different places.
Static functions are never dereferenced (destroyed). Neither are the variables. Static functions hold onto more memory at the start, but depending on what the program is doing, may be faster.
But, if you have multiple entry points into the static function you can introduce bugs.
-
Apr 1st, 2003, 04:19 AM
#4
transcendental analytic
Aren't you refering to static local variables jim? if not then thats something i didn't know.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Apr 15th, 2003, 01:44 AM
#5
Yep, jim's confusing things here.
Anyway, if it's not within class scope, a static function is simply only available withing the source file it is defined in.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
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
|