Solved

Header A needing Header B needing Header A.

Posted on 2008-06-16
3
151 Views
Last Modified: 2010-04-21
Hi,

What is the best/tidiest way of removing the problem of "Header A" needing something from "Header B" which in turn needs something from "Header A".

Thanks,
Uni
0
Comment
Question by:Unimatrix_001
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 45

Accepted Solution

by:
sunnycoder earned 250 total points
ID: 21794986
One way is forward declaration. If a type uses only pointers of another type, you can use a fwd declaration.
Else you can divide the contents into multiple header files ... say header C and move dependencies to it. That should break the cycle.

If you can provide details of your exact need, may be we can help better

0
 
LVL 86

Assisted Solution

by:jkr
jkr earned 250 total points
ID: 21795007
Usually forward declarations (see http://en.wikipedia.org/wiki/Forward_declaration). I.e.


//a.h
 
class B; // forward declaration
 
class A {
 
protected:
 
B* b;
};
 
//b.h
#include "a.h"
 
class B: {
 
protected:
 
A* a;
};

Open in new window

0
 
LVL 3

Author Closing Comment

by:Unimatrix_001
ID: 31467672
Thanks both. :)
0

Featured Post

Ready to get started with anonymous questions?

It's easy! Check out this step-by-step guide for asking an anonymous question on Experts Exchange.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

626 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question