Click to See Complete Forum and Search --> : DWORD static vs static DWORD


Quell
May 23rd, 2008, 10:35 AM
Hey.

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


DWORD static foo();


and

static DWORD foo();


Thx in advance.

laserlight
May 23rd, 2008, 10:49 AM
No real difference. The static keyword is applied to the function, not the return type.

Duoas
May 23rd, 2008, 01:05 PM
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.

void foo( const char* x )
is the same as
void foo( char const* x )
is the same as
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.

laserlight
May 23rd, 2008, 01:08 PM
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.

Duoas
May 23rd, 2008, 01:24 PM
Yoinks!

You are right. :-S

Quell
May 26th, 2008, 12:30 AM
Thx alot, that explains it :D

Lindley
May 26th, 2008, 12:58 AM
Fun fact: You should *never* declare
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.