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

  • Home
  • SEARCH
  • 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 8894633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:33:04+00:00 2026-06-14T23:33:04+00:00

I know below using C1::fn; will bring fn(…) functions declared in C1 to C2,

  • 0

I know below using C1::fn; will bring fn(…) functions declared in C1 to C2, but I want to know what’s the best practice for such using in design?

If fn() functions are not using C1 state, should I declare a helper class is the better way?
If fn functions are using C1 state, is using breaking encapsulation?

I appreciate if you can even mention some using cases in C++11. Like using the using Base::Base; constructor instead of calling it from derived member initializer?

class C1
{
  //...
  public:
    int fn(int j) { ... }
    double fn(double w) { ... }
    void fn(const char * s) { ... }
};

class C2 : public C1
{
  //...
public:
  //...
  using C1::fn;
  double fn(double) { ... };
};
  • 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-06-14T23:33:05+00:00Added an answer on June 14, 2026 at 11:33 pm

    If fn functions are using C1 state, is using breaking encapsulation?

    This using statement doesn’t break encapsulation; it doesn’t expose any private state from C1 or prevent C1 maintaining its invariants. It’s purely a convenient way to expose whatever other fn members C1 has – in this case int fn(int) – so they can be considered when resolving calls. Think of it as functionally equivalent to…

    class C2 : public C1
    {
        ...
        inline int fn(int j) { return C1::fn(j); }
    };
    

    …but better because you don’t have to manually add and remove functions to keep in sync with C1’s list of overloads.

    If fn() functions are not using C1 state, should I declare a helper class is the better way?

    If they’re not using C1 state, then they should be static or non-members. Helper classes are an ugly idea in my opinion. Namespaces are the normal method for grouping functionality in C++. I’m fully aware of Professor Lakos’s recommendations to use classes and understand all the arguments, and still disagree. Happy to run through it if the mention of helper classes was more than a passing thing for you.

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

Sidebar

Related Questions

I want to know is below code correct ? I have following code which
I want to know if the below code: <?php printf (%s, $some_variable); ?> is
I know that technically all three ways below are valid, but is there any
I want to know if the code below removes all input type='text' values back
I don't know what is the error behind the codes below, All I want
Note: Sorry for the amount of pseudo code below, but I didn't know how
I have some code below which will not run due to me not being
I don't know the best way to ask this, but let me explain the
I want to design a webpage as shown in the image below. There are
I know the method below isn't meant to work with any Entity, and its

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.