Unnamed/anonymous namespaces vs. static functions

后端 未结 11 2002
一个人的身影
一个人的身影 2020-11-22 03:27

A feature of C++ is the ability to create unnamed (anonymous) namespaces, like so:

namespace {
    int cannotAccessOutsideThisFile() { ... }
} // namespace
<         


        
11条回答
  •  长发绾君心
    2020-11-22 04:21

    In addition if one uses static keyword on a variable like this example:

    namespace {
       static int flag;
    }
    

    It would not be seen in the mapping file

提交回复
热议问题