CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Aug 2003
    Posts
    938

    DWORD static vs static DWORD

    Hey.

    I was wondering when u have a member function foo, what is the diffrence between:

    Code:
    DWORD static foo();
    and
    Code:
    static DWORD foo();
    Thx in advance.

  2. #2
    Join Date
    Jan 2006
    Location
    Singapore
    Posts
    6,765

    Re: DWORD static vs static DWORD

    No real difference. The static keyword is applied to the function, not the return type.
    C + C++ Compiler: MinGW port of GCC
    Build + Version Control System: SCons + Bazaar

    Look up a C/C++ Reference and learn How To Ask Questions The Smart Way
    Kindly rate my posts if you found them useful

  3. #3
    Join Date
    May 2008
    Posts
    96

    Re: DWORD static vs static DWORD

    There's no actual difference at all. That's one of those things that C and C++ doesn't actually care about, but which programmers tend to do just one way for aesthetics.

    Code:
    void foo( const char* x )
    is the same as
    Code:
    void foo( char const* x )
    is the same as
    Code:
    void foo( char* const x )
    We just prefer to read the first form as "a constant char pointer" (which makes more sense in Romanic languages) over "a char constant pointer" or "a char pointer constant".

    Hope this helps.

  4. #4
    Join Date
    Jan 2006
    Location
    Singapore
    Posts
    6,765

    Re: DWORD static vs static DWORD

    Eh, that's not correct, Duoas. The first two are indeed effectively the same, but the third is different since the const applies to the pointer.
    C + C++ Compiler: MinGW port of GCC
    Build + Version Control System: SCons + Bazaar

    Look up a C/C++ Reference and learn How To Ask Questions The Smart Way
    Kindly rate my posts if you found them useful

  5. #5
    Join Date
    May 2008
    Posts
    96

    Re: DWORD static vs static DWORD

    Yoinks!

    You are right. :-S

  6. #6
    Join Date
    Aug 2003
    Posts
    938

    Re: DWORD static vs static DWORD

    Thx alot, that explains it

  7. #7
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    10,895

    Re: DWORD static vs static DWORD

    Fun fact: You should *never* declare
    Code:
    void foo( const char **x )
    if you ever expect to pass a non-const char** to the function. Visual Studio allows it, but the standard doesn't----in particular, gcc and g++ will throw an error.

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