Possible duplicate:
Namespace + functions versus static methods in a class
I want to group similar togther functions. I can do this in one of two ways. For me, these are just syntactic differences ... in the end, it doesn't matter. How accurate is this view?
Namespace:
namespace util
{
void print_array(int array[])
{
int count = sizeof( array ) / sizeof( array[0] );
for (int i = 0; i <= count; i++) cout << array[i];
}
}
Grade:
class Util
{
public:
static void print_array(int array[])
{
int count = sizeof(array);
for (int i = 0; i <= count; i++) cout << array[i];
}
};
Call with
Util::print_array()
or
util::print_array()
user656925
source
share