如何可以在C++类中声明public,private或protected?
有没有办法伪造它?
是否有任何可以模拟最接近行为的C++宏/模板/魔术?
Util.h (图书馆)
class Util{
//note: by design, this Util is useful only for B and C
//Other classes should not even see "Util"
public: static void calculate(); //implementation in Util.cpp
};
Run Code Online (Sandbox Code Playgroud)
Bh (图书馆)
#include "Util.h"
class B{ /* ... complex thing */ };
Run Code Online (Sandbox Code Playgroud)
Ch (图书馆)
#include "Util.h"
class C{ /* ... complex thing */ };
Run Code Online (Sandbox Code Playgroud)
Dh (用户)
#include "B.h" //<--- Purpose of #include is to access "B", but not "Util"
class D{
public: static …Run Code Online (Sandbox Code Playgroud)