Remix.run Logo
kragen an hour ago

No, in C++ it's literally impossible. The language provides no way to define a proxy class you can call arbitrary methods on. You have to generate a fresh proxy class every time you have a new abstract base class you want to interpose, either by hand, with a macro processor, or with run-time code generation. There's no language mechanism to compile code that calls .fhqwhgads() successfully on a class that doesn't have a .fhqwhgads() method declared.

bluGill an hour ago | parent [-]

you don't call fhqwhgads() on your proxy class though. You call runFunction("fhqwhgads") and it all compiles - the proxy class then string matches on the arguments. Of course depending on what you want to do it can be a lot more complex. That is do manually what other languages do for you automatically under the hood.

Again, this is not something you should do, but you can.

kragen 24 minutes ago | parent [-]

That doesn't provide the same functionality, because it requires a global transformation of your program, changing every caller of .fhqwhgads(). By contrast, in OO languages, you typically just define a single method that's a few lines of code. You're sinking into the Turing Tarpit where everything is possible but nothing of interest is easy. Before morning you'll be programming in Brainfuck.