Incase it doesn't show up:

you are viewing a single comment's thread
view the rest of the comments
[–] 5 points 2 years ago (8 children)

How do you implement an interface in C++ without an abstract class?

  • source
  • parent
  • hideshow 8 child comments
  • [–] 3 points 2 years ago (4 children)

    Ask Bjarne to add interfaces enough many times until he gives in.

    On a more serious note, I’m not exactly sure what the best C++ practice is. I guess you just have to live with abstract classes if you really want interfaces.

  • source
  • parent
  • hideshow 4 child comments
  • [–] 6 points 2 years ago (3 children)

    An abstract class with no member variables serves the same purpose in C++.

  • source
  • parent
  • hideshow 3 child comments
  • [–] 2 points 2 years ago (2 children)

    The only problem is to ensure the entire team agrees to only use it like an interface and nothing else. But I guess that’s the only proper way to do it in C++, for now.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 1 point 2 years ago (2 children)

    I know at least three ways, one of them involves variadic macros.

    You don't even need to look that far, take any sufficiently aged library, like OpenGL.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 1 point 2 years ago (1 child)
  • [–] 2 points 2 years ago

    Yet I still had an urge to explain an obvious thing. Because it's C++, so everyhing goes. There are even tools to auto-generate C++ interfaces, because of course someone decided that C++ is inadequate and must be improved using some kind of poorly-documented ad-hoc extension language on top of C++.

  • source
  • parent