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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:54:31+00:00 2026-06-12T17:54:31+00:00

So I have been stuck on this problem of sharing a function from one

  • 0

So I have been stuck on this problem of sharing a function from one class to another and every solution I have found so far as not solved my problem.
One instance is here(I assure you there are others), [http://software.intel.com/en-us/articles/cdiag436]

Bar.h

#ifndef __Bar_h_
#define __Bar_h_
#include "BaseApplication.h"  
#include <Foo.h>  

class Foo;  
Foo *foo;  

class Bar : BaseApplication
{
   public:
Bar(void);
~Bar(void);
   protected:
virtual void barCreate(void);
};
#endif

Bar.cpp

#include "Bar.h"
#include <Foo.h>
Bar::Bar(void){}
Bar::~Bar(void){}
void Bar::barCreate(void)
{
     if(foo->foobar()==true) //error: pointer to incomplete class type is not allowed
        {//stuff}
}

Foo.h

#ifndef __foo_h_
#define __foo_h_
class Foo
{
public:
Foo(void);
~Foo(void);
bool foobar(void);
};
#endif

Foo.cpp

#include "Foo.h"
Foo::Foo(void){}
bool Foo::foobar(void){ return true; }

If I could get some pointers or explanation of where i’m going wrong that would be great.

  • 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-12T17:54:32+00:00Added an answer on June 12, 2026 at 5:54 pm

    You are misreading the error. It is not complaining about having a pointer to an incomplete type, but about dereferencing it.

    if(foo->foobar()==true)
    

    At this point the type of foo is an incomplete type, so the compiler cannot check whether it will have a foobar member function (or member functor).

    Basically for an incomplete type you can declare and define pointers or references, declare interfaces (functions that take or return the type). But other than that you cannot create objects of the type, or use the pointers/references for anything other than copying the pointer/reference.

    Regarding what you are doing wrong, you need to look to your real files in more details. Either you are not including the header that defines Foo, or you have multiple Foo types (different namespaces? one defines the type, another has the forward declaration) or your include guards are wrong and even if you include the header the guard discards the contents of the header. Note that after inclusion of the header that defines Foo you don’t need to (and should not) provide a forward declaration of the type, as that can easily lead to multiple declarations of Foo in different contexts. If removing the forward declaration fails to compile, figure out why and fix that.

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

Sidebar

Related Questions

Hope to get solution to this problem. I have been stuck on it since
So the problem.. I have been stuck with this one for a good month
I have been stuck on this problem for quite awhile... I hope someone out
I have been stuck on this problem for a while now. I want to
im new to iphone sdk programming, and have been stuck on this problem for
I've been stuck with this problem for over a week now. Hopefully some one
I have been stuck with this problem for quite some time now and i
I'm new to android and have been stuck on this problem for a long
I have been really stuck on this problem. My validation for my model fails
I have been stuck with this problem for a while now, and I just

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.