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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:18:26+00:00 2026-05-27T07:18:26+00:00

I have the following class definition: class IRenderable { public: virtual void Render( wxBitmap

  • 0

I have the following class definition:

class IRenderable {
 public:

    virtual void Render( wxBitmap * ) = 0;
}

class MyClass : public wxWindow, public IRenderable {

public:

/* costructor, destructor etc... */


    void RenderBitmap( wxBitmap *bitmap )
    {
        // code
    }

}

where wxWindow and wxBitmap are classes belonging to wxWidgets library (a C++ portable library for writing GUI applications).

I am using Visual C. The following piece of code is wrong:

MyClass *c = new MyClass(...);
wxWindow *w = (wxWindow *)c;
IRenderable *r_page = (IRenderable *)w;
// bitmap is allocate somewhere else           
r_page->RenderBitmap( bitmap );

because i get a runtime error:

Run-Time Check Failure #0 – The value of ESP was not properly saved
across a function call. This is usually a result of calling a
function declared with one calling convention with a function pointer
declared with a different calling convention.

What’s going on?

What i am doing is the following. A third-party library (wxAUI) get pointers to wxWindow in order to manage them. I have sublcassed wxWindow (MyClass) to add some specific code. So, instead of managing wxWindows objects i am using MyClass objects.
In some situations, i ask wxAUI to return me the wxWindow pointer of the “current” window, which should be a pointer to MyClass object. I want to call the RenderBitmap() method on those objects, so i need to cast it to IRenderable, but get that run-time error…

I do not have RTTI enable and don’t now if this would solve the problem…

  • 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-27T07:18:27+00:00Added an answer on May 27, 2026 at 7:18 am

    The problem is here:

    IRenderable *r_page = (IRenderable *)w;
    

    w doesn’t point to an IRenerable instance. I can see why you’d think it does, but it doesn’t.

    Avoid inheriting from multiple classes, and google “diamond inheritance” and “virtual inheritance” for better understanding.

    Extract from the wikipedia article on the diamond problem:

    C++ by default follows each inheritance path separately, so a D object
    would actually contain two separate A objects, and uses of A’s members
    have to be properly qualified. If the inheritance from A to B and the
    inheritance from A to C are both marked “virtual” (for example, “class
    B : virtual public A”), C++ takes special care to only create one A
    object, and uses of A’s members work correctly. If virtual inheritance
    and nonvirtual inheritance are mixed, there is a single virtual A and
    a nonvirtual A for each nonvirtual inheritance path to A. Please note
    that nonvirtual derivation of A in this case will be useless as direct
    access to any part of class A from class D will practically always end
    up with compile error.

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

Sidebar

Related Questions

I have a the following method definition in my class: virtual Calc* Compile( Evaluator*
I have following class public class ButtonChange { private int _buttonState; public void SetButtonState(int
I have the following abstract classes: public abstract class AbSuperClass1<K,S> { //class definition }
Let's say I have the following class definition : List<SomeClass>... public class SomeClass {
I have the following VB.NET class definition: <Serializable()> Partial Public Class Customers End Class
I have the following class definition: template<typename QueueItemT> class QueueBC { protected: QueueBC() {}
Let's have the following class definition: CThread::CThread () { this->hThread = NULL; this->hThreadId =
I have following class (as seen through reflector) public class W : IDisposable {
I have following test class @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = {/services-test-config.xml}) public class MySericeTest { @Autowired
I have the following class public class Car { public Name {get; set;} }

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.