Private class functions vs Functions in unnamed namespace

前端 未结 4 630
我在风中等你
我在风中等你 2020-12-25 10:22

I\'ve found myself that I tend not to have private class functions. If possible, all candidates to private class function rather I put in to unnamed namespace and pass all n

4条回答
  •  感情败类
    2020-12-25 10:49

    In the semi large projects where I usually work (more than 2 million lines of code) I would ban private class functions if I could. The reason being that a private class function is private but yet it's visible in the header file. This means if I change the signature (or the comment) in anyway I'm rewarded sometimes with a full recompile which costs several minutes (or hours depending on the project).

    Just say no to that and hide what's private in the cpp file.

    If I would start fresh on a large c++ project I would enforce PIMPL Idiom: http://c2.com/cgi/wiki?PimplIdiom to move even more private details into the cpp file.

提交回复
热议问题