CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2002
    Location
    La Plata, Buenos Aires
    Posts
    615

    static keyword help

    When programming with the Win32 API, when and where I should use the static keyword?

    Why in many C Win32 samples user defined functions are defined as static? This is an obsolete method of old C win32 programming ?

    Im programming in C++/W32 API with VC++ NET, not plain C, so i dont know if its necessary or not (my win32 programs work well without any STATIC definitions, except when I want a variable inside a function to retain values between calls).

    thank you!

  2. #2
    Join Date
    Apr 1999
    Posts
    27,449

    Re: static keyword help

    Originally posted by indiocolifa
    When programming with the Win32 API, when and where I should use the static keyword?

    Why in many C Win32 samples user defined functions are defined as static? This is an obsolete method of old C win32 programming ?
    No. A static function means that the function has file scope, i.e. it is not callable outside the file it is defined in, that's all. This has nothing to do with obsolescence, it's just the way the programmer decided to design their module.
    Im programming in C++/W32 API with VC++ NET, not plain C, so i dont know if its necessary or not
    This is a program design issue, not an API or compiler issue.
    (my win32 programs work well without any STATIC definitions, except when I want a variable inside a function to retain values between calls).
    a) static variables are not the same as static functions.

    b) There is nothing bad or good about using static, just like there is nothing bad or good about using new[] as opposed to declaring an array.

    These are all program design issues, and are not related to any operating system, API, or language used.

    Regards,

    Paul McKenzie

  3. #3
    Join Date
    Dec 2002
    Location
    La Plata, Buenos Aires
    Posts
    615

    Thumbs up

    thanks paul!


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