1

For my C++ DLLs, I am using the factory pattern with abstract interfaces.
In the disadvantages section of this article, it says:

An abstract interface method cannot return or accept a regular C++ object as a parameter. It has be either a built-in type (like int, double, char*, etc.) or another abstract interface. It is the same limitation as for COM interfaces.

Could you elaborate what this means? What exactly can I not do and why?
Is there any further reading available on this matter?

1 Answer 1

1

This statement does not look accurate. Abstract interface method can return or accept C++ class instance (or its pointer) as parameter. There is no COM-like limitation here. It might be unsafe though in case caller/callee are built using different compiler settings, alignments, using different allocators etc. in which case the same C++ class is defined slightly differently and the mismatch might result in unexpected behavior. That is, it is not about "cannot", it is about it might lead to unobvious problems.

A frequent example of the problem in question is passing CString as a parameter:

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.