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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:39:08+00:00 2026-05-18T10:39:08+00:00

What are they, what’s the different between them? Many sources, like Wikipedia , claim

  • 0

What are they, what’s the different between them?

Many sources, like Wikipedia, claim they’re the same thing, but others explicitly say the opposite, like sbi in this question:

First: “Visitor Pattern is a way to simulate Double Dispatching in C++.” This is, erm, not fully right. Actually, double dispatch is one form of multiple dispatch, which is a way to simulate (the missing) multi-methods in C++.

  • 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-18T10:39:09+00:00Added an answer on May 18, 2026 at 10:39 am

    They are the same.

    When you call a virtual method in C++, the actual method to run is based on the runtime type of the object them method is invoked on. This is called “single dispatch” because it depends on the type of a single argument (in this case, the implicit ‘this’ argument). So, for example, the following:

    class Base {
      public:
        virtual int Foo() { return 3; }
    }
    
    class Derived : public Base {
      public:
        virtual int Foo() { return 123; }
    }
    
    int main(int argc, char *argv[]) {
      Base* base = new Derived;
      cout << "The result is " << base->Foo();
      delete base;
      return 0;
    }
    

    When run, the above program prints 123, not 3. So far so good.

    Multiple-dispatch is the ability of a language or runtime to dispatch on both the type of the ‘this’ pointer and the type of the arguments to the method. Consider (sticking with C++ syntax for the moment):

    class Derived;
    
    class Base {
      public:
        virtual int Foo(Base *b) { cout << "Called Base::Foo with a Base*"; }
        virtual int Foo(Derived *d) { cout << "Called Base::Foo with a Derived*"; }
    }
    
    class Derived : public Base {
      public:
        virtual int Foo(Base *b) { cout << "Called Derived::Foo with a Base*"; }
        virtual int Foo(Derived *d) { cout << "Called Derived::Foo with a Derived*"; }
    }
    
    int main(int argc, char *argv[]) {
      Base* base = new Derived;
      Base* arg = new Derived;
    
      base->Foo(arg);
    
      delete base;
      delete arg;
      return 0;
    }
    

    If C++ had multiple-dispatch, the program would print out “Called Derived::Foo with a Dervied*”. (Sadly, C++ does not have multiple-dispatch, and so the program prints out “Called Derived::Foo with a Base*”.)

    Double-dispatch is a special case of multiple-dispatch, often easier to emulate, but not terribly common as a language feature. Most languages do either single-dispatch or multiple-dispatch.

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

Sidebar

Related Questions

They have all different sizes but how about performance issue between each other ?
They talk about the different utilization instances, but I can't find a single place
They are located under: share\gtk-2.0\demo But none of them contains a main function, how
They both do the same thing. Is one way better? Obviously if I write
They have states for things like pressed, focused, disabled, but is it possible to
They seem to accomplish the same thing in Objective C. What can one do
They seem to be doing the same thing... Is one modern and one old?
They are same, but which one should I use? http://docs.python.org/library/os.html : os.sep The character
They both seem to do the same thing - why would you use one
They can be defined like this Struct.new(:x, :y) But what can usefully be done

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.