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 5986577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:41:29+00:00 2026-05-22T22:41:29+00:00

Possible Duplicate: Why shall I use the “using” keyword to access my base class

  • 0

Possible Duplicate:
Why shall I use the “using” keyword to access my base class method?

Hi,

I can’t find out why I needed the keyword using in the following case:

// Pure virtual class.
class Visitor
{
  public:
      void operator()(Ast&);

      virtual void operator()(Node&) = 0;
};

// Define the default visit methods.
class DefaultVisitor : public Visitor
{
  public:
    using Visitor::operator();      // First 'using' needed.

    virtual void operator()(Node&);
};

// A visitor using DefaultVisitor's behaviour.
class AVisitor : public DefaultVisitor
{
  public:
    using Visitor::operator();      // Second 'using' needed.

    virtual void operator()(Node&);
};

Without the two using statements, the public non-virtual method declared and defined in Visitor, void operator()(Ast&);, is not visible when called from AVisitor. For example:

AVisitor v;
Ast* ast = new Node(); // Node is-a Ast
v(*ast); // should call Visitor::operator()(Ast&);

will not compile, saying the method void operator()(Ast&) does not match anything in AVisitor. The only solution is to use using keyword to import the abstract methods of the base class. But why ? Since it is public, I don’t understand why this is needed.

Thank you.

  • 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-22T22:41:29+00:00Added an answer on May 22, 2026 at 10:41 pm

    See this
    Why should I use the "using" keyword to access my base class method?

    Also this

    using

    The using keyword is used to import a
    namespace (or parts of a namespace)
    into the current scope. Example code:
    For example, the following code
    imports the entire std namespace into
    the current scope so that items within
    that namespace can be used without a
    preceeding “std::”.

    using namespace std;

    Alternatively, the next code snippet
    just imports a single element of the
    std namespace into the current
    namespace:

    using std::cout;

    Related Topics: namespace

    Using is for namespace specifications/use – not as I think you are trying to use it.

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

Sidebar

Related Questions

Possible Duplicate: Allen Holub wrote “You should never use get/set functions”, is he correct?
Possible Duplicate: What does “this” mean in a static method declaration? i go through
Possible Duplicate: Should I use uint in C# for values that can’t be negative?
Possible Duplicate: Why not use tables for layout in HTML? Under what conditions should
Possible Duplicate: How do you send email from a Java app using Gmail? How
Possible Duplicate: StructureMap singleton usage (A class implementing two interface) I'm currently designing a
Possible Duplicate: How can I convert ereg expressions to preg in PHP? I need
Possible Duplicate: How do I find .bash_profile and add to my shell's initialization file?
Possible Duplicate: Adding label and text box control to GUI Can someone help me
Possible Duplicate: NAnt or MSBuild, which one to choose and when? What is the

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.