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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:16:42+00:00 2026-05-23T01:16:42+00:00

I have a class that has two functions, both of which take a different

  • 0

I have a class that has two functions, both of which take a different set of parameters and both of which have default arguments like so:

void PlaySound(const std::string &soundName, int channel = 0, bool UseStoredPath = true);

void PlaySound(FMOD::Sound* sound, int channel = 0);

I’ve found how to do default argument overloads from the tutorial here

http://www.boost.org/doc/libs/1_37_0/libs/python/doc/v2/overloads.html

as well as how to do function overloads taking different parameter types here

http://boost.2283326.n4.nabble.com/Boost-Python-def-and-member-function-overloads-td2659648.html

and I end up doing something like this…

BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(PlaySoundFromFile, Engine::PlaySound, 1, 3)
BOOST_PYTHON_MODULE(EngineModule)
{
    class_<Engine>("Engine")
        //Sound
        .def("PlaySound", static_cast< void(Engine::*)(std::string, int, bool)>(&Engine::PlaySound));
}

The problem is I really have no idea how to use them together at the same time. I’d like to avoid having to change my base class function definitions.

Can someone who’s done this before, or knows how to do this help me out?

Thanks in advance

  • 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-23T01:16:43+00:00Added an answer on May 23, 2026 at 1:16 am

    This works for me:

    BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(
        PlaySoundFromFile, Engine::PlaySound, 1, 3)
    BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(
        PlaySoundFromFMOD, Engine::PlaySound, 1, 2)
    
    BOOST_PYTHON_MODULE(EngineModule)
    {
        class_<Engine>("Engine")
            .def("PlaySound", static_cast< void(Engine::*)
                (const std::string&, int, bool)>
                (&Engine::PlaySound), PlaySoundFromFile())
            .def("PlaySound", static_cast< void(Engine::*)
                (FMOD::Sound*, int)>
                (&Engine::PlaySound), PlaySoundFromFMOD())
        ;
    }
    

    The trick is that you need to tell each def() to use one of the overload specifiers (that seemed to be the biggest missing piece from what you had).

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

Sidebar

Related Questions

I have two classes defined in different h files and each class has some
I have a design that uses two outer columns, and within one of the
I have a program which uses an io_service and several threads. It instantiates some
Is it possible in C++ to have two classes, let's call them A and
I am trying to implement a forgotten password solution in rails. I have a
I am new to php, so sorry if this is lame. I have a
Well I am a new to VB.NET, converting a legacy system to .NET world.
I am new to JavaScript and I am having trouble understanding the scope of
Okay I've tried multiple things and looked for answers to this and I can't
So my current project is mostly in Python, but I'm looking to rewrite 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.