I've been reading a bit about static functions and static member functions. From my understanding if a function is declared static then this function is only visible to it's translation unit and nowhere else. A static member function instead is a function that can be called without instantiating any object of its class (so you can use it like it was in a name space).
To clarify with static function I mean something like
static int foo(int a, int b)
{
return a + b;
}
And with static member function I mean
struct MyClass
{
static int foo(int a, int b)
{
return a + b;
}
}
Is this the only difference? or is the visibility within the same translation unit still a common feature for the two of them?
thispointer). It can be seen as a class-function instead of an object-function, and is available for all translation units which have the declaration of it. A static non-member (also called namespace-scope) function have static storage duration and internal linkage.staticis one of the keywords with different meanings depending on context. Don't get confused by the same keyword being used for different things (en.cppreference.com/w/cpp/keyword/static)__declspecdirective. So even for a static member function, it may not be visible outside its translation unit in Windows unless you make it so.