c++ design pattern question. single interface multiple implementations? [duplicate] - c++

This question already has answers here:
Closed 11 years ago.
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

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.

Related

What is the seperate implementation interfact class idiom and when do I use it? [duplicate]

This question already has answers here:
Is the PIMPL idiom really used in practice?
(12 answers)
Closed 7 years ago.
I have occasionally come across what I can only describe as the "interface-implementation idiom", where a class is separated into an "interface class" and an "implementation class".
What is the philosophy or reasoning behind this?
What is an example usage of this methodology? What does an example of such a class system look like and why would it be useful to separate a class into an interface and an implementation?
I think what you're talking about is also known as the pImpl pattern. There is lots of discussion about it at Why Should the pImpl idiom be used. That question is also marked as a duplicate of an older question/answer with more information.

Calling a .net function from C++ [duplicate]

This question already has answers here:
How do I call a .NET assembly from C/C++?
(9 answers)
Closed 8 years ago.
I want to use this function to zip up a folder from a C++ console application. No examples are given in the article of how to use the function from C++, just C# or VB, and I can't find any other code samples anywhere.
The article doesn't really even clarify whether the function is available in C++. Is this function supported in C++? And if so, how do I call it?
Thanks.
This doesn't answer your specific question of calling that .NET method you requested, but, if you want to compress some files using native C++, look at using Zlib and there is a contribution app called minizip which you can use for opening / creating zip archives.

Reflection in C++ [duplicate]

This question already has answers here:
Why does C++ not have reflection?
(15 answers)
Closed 9 years ago.
I am currently porting a game from Cocos2d written in ObjectiveC to Cocos2d-x in C++. Now the objective C guys have used Reflection to populate modal classes from a json object. Is the same possible in C++ Can we use reflection in C++ ?
Kind Regards
As mentioned in the comments, C++ has no reflection.
The default solution is to register all the symbols that you need in an associative array, like unordered_map. Here are examples of that.

What is an equivalent to instanceof in C++? [duplicate]

This question already has answers here:
C++ equivalent of java's instanceof
(5 answers)
Closed 9 years ago.
How can I check the class type in c++?
In Java I used instanceof.
I prefer not to use dynamic cast, but only classic c++.
Is there any way?
Clarification:
It isn't a duplicate of another question in StackOverflow, since I asked how can I find it without using of dynamic_cast. In the other question, the answer was to use it. Please don't mark it as a duplicated.
There is no way to check class type without RTTI or it's home brew substitution. If application compiled without RTTI information about type is not stored anywhere.

Good coding guidelines tool for C++? [duplicate]

This question already has answers here:
Closed 13 years ago.
Possible Duplicate:
What tools exist for comparing C++ code to coding guidelines?
Can any one suggest any good coding guidelines tool for C++ which must be configurable according to specific requirements?
I've always found the Google C++ Style Guide to be a good one.