lundi 23 mars 2015

C static keyword vs C++ private scope?


As a sequel to this question: Best practice static C function or private C++ method


Which is the most adequate C++ replacement for



static void bar() {
}


appearing in a c module foo.c?


A private function in a class foo



class foo {
void bar();
};

void foo::bar() {
// ...
}


or as module private function in an unnamed namespace in the foo.cpp translation unit



namespace {
void bar {
// ...
}
}


Or isn't there any way to compare these two on a semantical level?




Aucun commentaire:

Enregistrer un commentaire