Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6078841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:52:44+00:00 2026-05-23T10:52:44+00:00

Suppose there’s a third party class named (including namespace) other::OtherClass . And this is

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T10:52:44+00:00Added an answer on May 23, 2026 at 10:52 am

    Vendors have to expose some amount of their library to clients through the header files they provide.

    That being said, there are techniques for hiding data and functions within an implementation. One of the more common techniques is to provide public proxy classes and factory functions, which expose only a mimimal amount of public functionality to clients.

    As to your second question, it’s better to use references and pointers to the third-party types in your headers, since you can forward-declare the types within your header file as:

    class other::OtherClass;
    

    within needing to actually include the third-party header files. This does not expose any of the third-party details to clients of your libraries.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose there is a singleton class in an assembly named Common . This DLL
Suppose there is this interface: class A{ public: virtual foo()=0; }; And a class
Suppose there is a file named as SUN.txt File contains : a,b,dd,ss, I want
Suppose there is this code: class CFoo { public: CFoo() { iBar = new
Suppose there is this text file: abcd,efgh,ijkl mnop,qrst 12345,78 poqs,90st I want to read
Suppose there is a System A which gives some output. This output is used
Suppose there is a text like this: |-SAMPLE-D2 |---SAMPLE-D1 |---SAMPLE3 I want to count
Suppose there is a text file containing these in the fallowing style: name: natalie,
Suppose there is a file ( test.txt ) with content. testing php data employee
Suppose there is a function with 1000 code of line named LongFunction, and we

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.