While refactoring some old code I have stripped out a number of public methods that should actually of been statics as they a) don\'t operate on any member data or call any othe
A case where one might use class
(or struct
) over namespace
is when one needs a type, for example:
struct C {
static int f() { return 33; }
};
namespace N {
int f() { return 9; }
}
template
int foo() {
return T::f();
}
int main() {
int ret = foo();
//ret += foo(); // compile error: N is a namespace
return ret;
}