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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:26:40+00:00 2026-05-25T23:26:40+00:00

I am trying to compile code with the following structure under codeblocks: class a

  • 0

I am trying to compile code with the following structure under codeblocks:

class a : public cppcms::application (has virtual members) {
 public:
   a() : b_inst(this) {}
   ...
   b b_inst;

}

class b {
  public:
    b(a* ptr) : a_ptr(ptr) {}
  private:
    a* a_ptr;
  ...
}

I am trying to put this together with codeblocks/g++ and get the following error message (at the linking stage):

undefined reference to `vtable for b (In function b: …)

I tried pulling of the same thing with a reference, same result. I tried to change a::b_inst to a pointer and creating an instance of b with new in the constructor (codepart), same result.
What is the right way to do this?

By the way, if I do not add the pointer passing on construction, the code works, so i think it is not resolved by the answer here

  • 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-25T23:26:40+00:00Added an answer on May 25, 2026 at 11:26 pm

    undefined reference to `vtable for b (In function b: …)

    That means probably you haven’t implemented all of b‘s virtual methods. gcc emits the vtable when the first one is defined AFAIK.

    That means it has nothing to do with the implementation of your constructor.

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

Sidebar

Related Questions

I'm trying to compile the following code: public class BaseRequest<TResponse> where TResponse : BaseResponse
I'm trying to compile following code in VC++ 2010: class Base { public: std::wstring
I'm trying to compile a POCO with this code public class MenuItem { public
I am trying to compile the following code: public static void RequireOrPermanentRedirect<T>(this System.Web.UI.Page page,
I'm trying to compile the following code: class MyClass { def foo(): this.type =
I am trying to compile the following code in my test application on windows
I'm trying to compile the following code under VC2010. struct CircValRange { double a,b;
While trying to compile the code below: template <class T> struct scalar_log_minimum { public:
When trying to compile the following code, I am getting a warning that line
I am trying to compile the following code: private String dataToString(){ Map data =

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.