private and public in namespace cpp

C++
// thing.cpp

namespace thing
{
    namespace   // anonymous namespace
    {
        int x = 1;
        int y = 2;

        int sum(int a, int b)
        {
            return a + b;
        }
    }

    int getX() 
    {
        return x;
    }

    int getSum()
    {
        return sum(x, y);
    }
};
#include <cstdio>
#include "thing.hpp"

int main(int argc, char **argv)
{
    printf("%d\n", thing::getX());     // OK
    printf("%d\n", thing::getSum());   // OK
    printf("%d\n", thing::sum(1, 2));  // error: ‘sum‘ is not a member of ‘thing’    
    printf("%d\n", thing::y);          // error: ‘y‘ is not a member of ‘thing’    
}

Source

Also in C++: