What is the C ++ equivalent for a translation unit, a local function static
in C?
For example, having the following in bar.c
:
static void bar() {
}
In C ++, this will be written as a private member function, e.g.
class foo {
void bar();
};
void foo::bar() {
}
The private member function implicitly enters a pointer this
as a parameter, so it is not very similar to a style function static
. But even a member function private static
bar()
will be visible in the public interface (and will remain available to the linker) and will not be comparable.
Although the available scope of these functions is similar, these parameters do not look like good replacements for the style function syntax mentioned static
.
Is an equivalent function in an unnamed namespace visible only for the current translation unit?
namespace {
void bar() {
}
}