![]() |
| | #1 |
| 1479 Join Date: Aug 2003
Posts: 253
| Question about Static variables and functions. Code: static int add(int, int);
__________________ Knowledge is power and I want it all -0RealityFusion0- |
| RealityFusion is offline | |
| | #2 |
| Code Goddess Join Date: Sep 2001
Posts: 9,661
| >What is the different between a function that uses static variables and a static function? The difference is that static local variables are not deprecated and static functions are. So you shouldn't be using static functions in C++ anyway. But if you must know, a static function has internal linkage instead of the default external linkage. That means that only code from the same translation unit (aka. file after preprocessing) can see and use that function when it's declared as static. The C++ equivalent is an unnamed namespace: Code: namespace {
int add(int, int);
}
__________________ My best code is written with the delete key. |
| Prelude is offline | |
| | #3 |
| Even death may die... Join Date: Apr 2003 Location: Malaysia
Posts: 970
| |
| Dante Shamest is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| question about static members and functions | e66n06 | C++ Programming | 5 | 01-07-2008 02:41 PM |
| Static variables in functions | tretton | C Programming | 1 | 04-08-2006 06:49 AM |
| Using private class members in static functions | sethjackson | C++ Programming | 2 | 09-23-2005 09:54 AM |
| Static variables and functions problem in a class | earth_angel | C++ Programming | 16 | 09-15-2005 12:08 PM |
| Static variables in functions | PJYelton | C++ Programming | 2 | 10-04-2002 01:41 PM |