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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:54:35+00:00 2026-06-15T19:54:35+00:00

I have a C++ object that is the child of a virtual class, and

  • 0

I have a C++ object that is the child of a virtual class, and I am trying to wrap in python. The file compiles, and I can import it into python, but when I try to call the function, I get an error:

In [3]: x
Out[3]: <beh.MappedBehaviourDomain at 0x23e7158>

//So, obviously the constructor is working (or at least thinks it is)

In [4]: x.subject_count()
---------------------------------------------------------------------------
ArgumentError                             Traceback (most recent call last)
/home/max/verk/btr-email/build/x86_64/bin/ipython in <module>()
----> 1 x.subject_count()

ArgumentError: Python argument types in
    BehaviourDomainWrap.subject_count(MappedBehaviourDomain)
did not match C++ signature:
    subject_count(BehaviourDomainWrap {lvalue})
    subject_count(BehaviourDomainWrap {lvalue})

I’m having a hard time understanding this error; this is my first time working with boost python and I don’t have much experience with C++. Here’s the relevant code:

// Instantiating class for use in boost python
struct BehaviourDomainWrap : BehaviourDomain, wrapper<BehaviourDomain>
{
    size_t subjectCount() const {
        return this->get_override("subjectCount")();
    // A bunch of other methods removed
}


BOOST_PYTHON_MODULE(beh) {

    class_<BehaviourDomainWrap, boost::noncopyable>("BehaviourDomainWrap")
        .def("subject_count", pure_virtual(& BehaviourDomainWrap::subjectCount))
    ;

    class_<MappedBehaviourDomain, bases<BehaviourDomainWrap> >
        ("MappedBehaviourDomain", init<std::string>())
    ;
}

What’s going wrong, and why?

  • 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-15T19:54:36+00:00Added an answer on June 15, 2026 at 7:54 pm

    I was passing in the wrapped version of the object rather than the base. I should have had:

    class_<BehaviourDomainWrap, boost::noncopyable>("beh")
        .def("subject_count", pure_virtual(& BehaviourDomain::subjectCount))
    ;
    
    class_<MappedBehaviourDomain, bases<BehaviourDomain> >
        ("mapped_beh", init<std::string>())
    ;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an object that has a child collection: class Person { public string
I have an Action entity, that can have other Action objects as child in
I have an object that I convert into NSData using an NSKeyedArchiver and then
I have an object that has properties, but when I try to access them,
I have a child object in the database that looks like this: CREATE TABLE
I have 2 objects like this public class Child { public virtual int ChildId
I have an object that has a few different List properties that contain child
I have a MenuObject class that represents a websites Top Menu. This object has
If I have the following domain object: public class Customer { public virtual Guid
I know that calling a virtual method from a base class constructor can be

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.