lundi 29 juin 2015

C++ abstract or interface classes?

I found this question: When to use abstract class or interface?. But it was asked for Java and C++ is different. There is multiple inheritence so maybe the answers are different too.

When shall I use an interface class ?

If I use the PIMPL idiom then there will be only one member which I only need to forward declare. And if I move the private functions into the PIMPL class then there will be only public and protected functions in a abstract class. So the difference between an abstract class like this and an ˙interface class is that in the interface class there shall be only pure virtual functions. Does it have any advantages over the previously mentioned one ?

Aucun commentaire:

Enregistrer un commentaire