Skip to content

Instantly share code, notes, and snippets.

Created May 2, 2017 01:14
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
public/private API class trick
namespace blink {
class RealClass : public RealBase {
static RealClass* Create();
void DoSomething();
// members here
namespace agent {
class AgentClass : public AgentBase {
AgentClass* Create();
void DoSomething();
// no data members; not a real class
AgentClass* AgentClass::Create() {
ScriptWrappable* self = RealClass::Create();
return reinterpret_cast<AgentClass*>(self);
void AgentClass::DoSomething() {
RealClass* self = static_cast<RealClass*>(reinterpret_cast<ScriptWrappable*>(this));
} // namespace agent
} // namespace blink
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment