The keyword static
is overloaded in the C++ language (i.e. it has multiple meanings). In the code that you presented:
struct MyStruct {
};
static float MyStaticFunction( MyStruct, MyStruct );
the meaning of static
is internal linkage (i.e. the symbol will not be usable outside of the current translation unit. If this is present in a header, then each including translation unit will get it's own copy of the function. In this case, usage is that of a free function:
MyStruct a,b;
float f = MyStaticFunction( a, b );
It seems from the attempt to use it that what you meant was using static
in this alternate scenario:
struct MyStruct {
static float MyStaticFunction( MyStruct, MyStruct );
};
where it has a different meaning: the member belongs to the class, not to a particular instance. In this case, the function can be called in one of two ways, the most common one is:
MyStruct a,b;
float f = MyStruct::MyStaticFunction( a, b );
even though the language also allows (I would not recommend using it, it might be confusing):
float f a.MyStaticFunction(a,b);
Where the confusion arises because it looks like calling a member function on a
, rather than calling a static member function on the class.