Suppose there's a third party class named (including namespace) other::OtherClass
.
And this is the header file.
class MyClass {
public:
...
private:
other::OtherClass other_class_;
...
}
If this header file was shipped in production, would this be considered exposing the implementation to the client?
On the other hand, is it a good idea or not to use a third party class in a public interface? (Note that this second example doesn't necessarily save that class into a private member.)
class MyClass {
public:
MyClass(const other::OtherClass& other_class);
...
private:
...
}
In the first example, the client has to know the size of other::OtherClass
and include the header file. In the second example, the client needs to be able to construct other::OtherClass
which also might need the header file if a factory was not provided.
Are there good excuses in doing any of the examples above?
If this is almost never a good idea, what is the usual way to design classes like above?