Code:
namespace util
{
void print_array(int array[])
{
int count = sizeof( array ) / sizeof( array[0] );
for (int i = 0; i <= count; i++) cout << array[i];
}
}
class Util
{
public:
static void print_array(int array[])
{
int count = sizeof(array);
for (int i = 0; i <= count; i++) cout << array[i];
}
};
util::print_array() // Namespace
Util::print_array() // Class
C++ - Namespace vs. Static Functions - Stack Overflow
Consider the example above from stackoverflow.
The static method is called from a class, similar to that of a namespace.
They are both valid when called although namespace is frowned upon because it is an extra language feature,
but the fundamental question is, which is which ?
The second question is, what to use ?
Furthermore, the static keyword in c hides the method; the method cannot be used outside that header, in that sense, a one-dimensional c programmer would be confused ?