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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:06:49+00:00 2026-05-25T11:06:49+00:00

I seem to be misunderstanding something related to build order dependencies in C++. So

  • 0

I seem to be misunderstanding something related to build order dependencies in C++. So I have this code, which defines a class that I use as a functionoid (object whose purpose is to substitute for passing a function pointer):

#include "Imports.h"

class X: public Y
{
public:

    X (T* t) { this->t= t; }
    virtual ~X(){}

    virtual void draw()
    {
        if (t->booleanReturningFunction())
        {
                t->someField.draw();
        }
    }

    T* t;
};

I’m getting a compiler error that complains about the “use of undefined type T” at the line numbers where I’m using T. However, Imports.h looks like:

//The goal of this file is to have all the typcally needed imports in one place.

#if !defined(IMPORTS_H)
#define IMPORTS_H

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <iostream>
#include <assert.h>
#include <cmath>
#include <fstream>

class T;
class X;
class Y;

#include "Y.h"
#include "X.h"
#include "T.h"

#endif // if !defined(IMPORTS_H)

With each “.h” file containing a definition of that class. Now T actually does have an X object in it (not a pointer, but an X object). But, as far as I can tell, there’s no circular dependency in the build order because X only has a pointer to T, right? Is there anything I’m missing that you can see just from this code? Help is much appreciated!

Edit: I solved my problem. The issue was that I was doing the above code inside a header file. The compiler understandably couldn’t compile t->booleanReturningFunction() based on a forward reference (it needed to see the class declaration to know what address to bind the function call to).

  • 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-25T11:06:49+00:00Added an answer on May 25, 2026 at 11:06 am

    I solved my problem. The issue was that I was doing the above code inside a header file. The compiler understandably couldn’t compile t->booleanReturningFunction() based on a forward reference (it needed to see the class declaration to know what address to bind the function call to).

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

Sidebar

Related Questions

I seem to get something fundamentally wrong. I have this HTML <div id=thumbnails> <a
I seem to have found a bug in jQuery UI that duplicates dragged elements
I seem to be suffering from some fundamental misunderstanding of the way that GWT
I seem to be having some problems with something simple here. I have some
Even after reading the documentation , I seem to have a fundamental misunderstanding about
I have a question about returning results from a pthread executed function. Related code:
I have the following HTML <div class=test>Click Me</div> <div class=something>hello</div> <div class=yes>yes!</div> <div class=taco>stackoverflow</div>
I seem to be a little lost on what to so about this, im
I seem to have a problem passing some strings on from one form to
I seem to have hit a snag while building my project using Ant. 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.