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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T14:50:18+00:00 2026-05-11T14:50:18+00:00

Update: This issue is caused by bad memory usage, see solution at the bottom.

  • 0

Update: This issue is caused by bad memory usage, see solution at the bottom.

Here’s some semi-pseudo code:

class ClassA { public:     virtual void VirtualFunction();     void SomeFunction(); }  class ClassB : public ClassA { public:     void VirtualFunction(); }  void ClassA::VirtualFunction() {     // Intentionally empty (code smell?). }  void ClassA::SomeFunction() {     VirtualFunction(); }  void ClassB::VirtualFunction() {     // I'd like this to be called from ClassA::SomeFunction()     std::cout << "Hello world!" << endl; } 

The C# equivalent is as follows: Removed C# example, as it’s not relevant to the actual problem.

Why isn’t the ClassB::VirtualFunction function being called when called from ClassA::SomeFunction? Instead ClassA::VirtualFunction is being called…

When I force implementation of the virtual function ClassA::VirtualFunction, like so:

class ClassA { public:     virtual void VirtualFunction() = 0;     void SomeFunction(); }  class ClassB : public ClassA { public:     void VirtualFunction(); }  void ClassA::SomeFunction() {     VirtualFunction(); }  void ClassB::VirtualFunction() {     // I'd like this to be called from ClassA::SomeFunction()     std::cout << "Hello world!" << endl; } 

The following error occurs at runtime, despite the derrived function deffinately being declared and defined.

pure virtual method called terminate called without an active exception 

Note: It seems like the error can be caused even by bad memory usage. See self-answer for details.

Update 1 – 4:

Comments removed (not releavnt).

Solution:

Posted as an answer.

  • 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. 2026-05-11T14:50:18+00:00Added an answer on May 11, 2026 at 2:50 pm
    class Base { public:    virtual void f() { std::cout << 'Base' << std::endl; }    void call() { f(); } }; class Derived : public Base { public:    virtual void f() { std::cout << 'Derived' << std::endl; } }; int main() {    Derived d;    Base& b = d;    b.call(); // prints Derived } 

    If in the Base class you do not want to implement the function you must declare so:

    class Base { public:    virtual void f() = 0; // pure virtual method    void call() { f(); } }; 

    And the compiler won’t allow you to instantiate the class:

    int main() {    //Base b; // error b has a pure virtual method    Derived d; // derive provides the implementation: ok    Base & b=d; // ok, the object is Derived, the reference is Base    b.call(); } 

    As a side note, be careful not to call virtual functions from constructors or destructors as you might get unexpected results.

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

Sidebar

Ask A Question

Stats

  • Questions 229k
  • Answers 229k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Yes. On a Rails' model association you can specify the… May 13, 2026 at 1:46 am
  • Editorial Team
    Editorial Team added an answer This is embarrassing as I found just the way to… May 13, 2026 at 1:46 am
  • Editorial Team
    Editorial Team added an answer I have figured out why this is happening. With the… May 13, 2026 at 1:46 am

Related Questions

Well I had an app I was developing in iPhone SDK 2.2 and I
Good morning all, I'm sure this is a gimme, but I have no idea
We've inherited a rather large Access DB that has some very strange (and unsettling)
I've created a page which combines an inline jQuery UI datepicker . I wan't

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.