2

Possible Duplicate:
How do you declare an interface in C++?

Hi,

What's the preferable way to create single interface and multiple implementations in c++?

For example, I'd like to implement kqueue for mac and epoll for linux and share the interface.

Thank you

1
  • I would in this case try to keep the interface in the header general enough so it works with either implementation, and just make two different detail source files and #ifdef #include the right one from a third one. This is not as elegant, but it works. The reason why I would go this way is that it is kind of pointless to use a sophisticated pattern that can decide at runtime if it is clear from the beginning that you will only ever use one implementation on a particular platform. Commented May 3, 2011 at 8:49

1 Answer 1

2

The Strategy Pattern is probably what you are looking for.
The Abstract Factory Pattern can help you fill in the right implementation when starting up.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.