|
-
May 23rd, 2008, 10:35 AM
#1
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.
-
May 23rd, 2008, 10:49 AM
#2
Re: DWORD static vs static DWORD
No real difference. The static keyword is applied to the function, not the return type.
-
May 23rd, 2008, 01:05 PM
#3
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.
-
May 23rd, 2008, 01:08 PM
#4
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.
-
May 23rd, 2008, 01:24 PM
#5
Re: DWORD static vs static DWORD
Yoinks!
You are right. :-S
-
May 26th, 2008, 12:30 AM
#6
Re: DWORD static vs static DWORD
Thx alot, that explains it
-
May 26th, 2008, 12:58 AM
#7
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|