473,324 Members | 2,531 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

compilation problem... WHY?

Welcome,
I will simplyfy my problem...

There are 3 classes in 3 files(actually 6, *.h and *.cpp). Every class uses
2 others.
These are *.h:
--------------------
....
include <B.h>
include <C.h>
....
class A
{
B b;
C c;
....
}
--------------------
....
include <A.h>
include <C.h>
class B
{
A a;
C c;
....
}
--------------------
....
include <A.h>
include <B.h>
class C
{
A a;
B b;
....
}

Why it dosn't compile? Unless I put before each class declaration of others:
class B;
class C;
etc...

Is it only solution?

Thanks,
Dariusz
Jul 22 '05 #1
3 1175
Dariusz Plygawko wrote:
Welcome,
I will simplyfy my problem...

There are 3 classes in 3 files(actually 6, *.h and *.cpp). Every class uses
2 others.
These are *.h:
--------------------
...
include <B.h>
include <C.h>
...
class A
{
B b;
C c;
...
}
--------------------
...
include <A.h>
include <C.h>
class B
{
A a;
C c;
...
}
--------------------
...
include <A.h>
include <B.h>
class C
{
A a;
B b;
...
}

Why it dosn't compile? Unless I put before each class declaration of others:
class B;
class C;
etc...

Is it only solution?

Thanks,
Dariusz


I'm sure there's a FAQ on circular dependencies.

In addition, your includes should use "A.h", "B.h", and "C.h", instead of <A.h>, etc...
Angle bracketed includes are for standard include files.
Jul 22 '05 #2
red floyd wrote:
Dariusz Plygawko wrote:
Welcome,
I will simplyfy my problem...

There are 3 classes in 3 files(actually 6, *.h and *.cpp). Every class
uses
2 others.
These are *.h:
--------------------
...
include <B.h>
include <C.h>
...
class A
{
B b;
C c;
...
}
--------------------
...
include <A.h>
include <C.h>
class B
{
A a;
C c;
...
}
--------------------
...
include <A.h>
include <B.h>
class C
{
A a;
B b;
...
}

Why it dosn't compile? Unless I put before each class declaration of
others:
class B;
class C;
etc...

Is it only solution?

Thanks,
Dariusz


I'm sure there's a FAQ on circular dependencies.

In addition, your includes should use "A.h", "B.h", and "C.h", instead
of <A.h>, etc...
Angle bracketed includes are for standard include files.


Everything the OR has mentioned is correct -- but there's a deeper
problem here. In the example the OP provided, how big is an instance
of class A?

Think about it. ;-)

HTH,
--ag

--
Artie Gold -- Austin, Texas
Oh, for the good old days of regular old SPAM.

Jul 22 '05 #3
In article <bq**********@sunnews.cern.ch>, Dariusz Plygawko
<Da**************@cern.ch> writes:
Why it dosn't compile? Unless I put before each class declaration of others:
class B;
class C;
etc...

I can't tell exactly what your problem is, but according to your example it
seems that your classes are recursiv. The compiler can't figure out when to
stop solving depencies and simply stops.

----- Posted via NewsOne.Net: Free (anonymous) Usenet News via the Web -----
http://newsone.net/ -- Free reading and anonymous posting to 60,000+ groups
NewsOne.Net prohibits users from posting spam. If this or other posts
made through NewsOne.Net violate posting guidelines, email ab***@newsone.net
Jul 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Alex Vinokur | last post by:
Hi, The code below has no problem with GNU g++ 3.3, but it has a problem with GNU g++ 3.4. What is reason for that? --------- foo.cpp : BEGIN --------- template <typename T> struct Boo
6
by: Joachim | last post by:
I made some project changes (which seems it doesn't help if I undo) which have created compilation error: " Server Error in '/PCSWebApp1' Application....
3
by: Dan | last post by:
Hi, I have a problem using an aspx page with a Control on it. I get the following error message Compiler Error Message: CS1595: 'Test.Class2' is defined in multiple places; using definition...
10
by: RedEagle | last post by:
Hi All! Do you remember me? I am that desperate who had this error for a while: --- Compilation Error Description: An error occurred during the compilation of a resource required to service...
0
by: Mythran | last post by:
I'm have 2 primary errors that seem to occur. 1.) In my ASP.Net application, I have 3 libraries (BLL, DAL, and Schema) that are used for the 4th and 5th UI libraries. All of the dependant...
3
by: seema | last post by:
Hi all, I am new to C programming. I have problem compiling a sample , #include <stdio.h> int getuniqueaddress1(){ return 1; } int getuniqueaddress2(){ return 2;
4
by: Bob | last post by:
Hi, In VS2003 conditional compilation constants and their state could be defined at project level. I was using this to control what features where offered by various builds. i.e....
35
by: mwelsh1118 | last post by:
Why doesn't C# allow incremental compilation like Java? Specifically, in Java I can compile single .java files in isolation. The resulting individual .class files can be grouped into .jar files....
6
by: maxwell | last post by:
I'm trying to use the gpp utility (Gnu points to http://en.nothingisreal.com/wiki/GPP) to do conditional compilation in Python, and I'm running into a problem: the same '#' character introduces...
1
by: Alex Vinokur | last post by:
Hi, I have compilation problem on SUN CC compiler with template while using option -m64 (64-bit addressing model). No problem while using option -m32 (32-bit addressing model) $ CC -V CC:...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.