473,394 Members | 1,916 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,394 software developers and data experts.

Headers cross-calling

Hi all :)

I have an-easy-to-resolve (I am sure but I am obviously unable to
figure the answer out) problem for C++ gurus.

Here's the situation I have fallen into...

2 header files: H1.h & H2.h
--------------------------------------------------------------------
--- H1.h
--------------------------------------------------------------------
#include "H2.h" // <------ error at compilation (unknown type:
T1c in the T2),
// without the #include: unknown
type T2 in the T11
class T11
{
<...>
T2 method();
}

template <typename Tclass T12 :
: T11
{
<...>
}

typedef T1<charT1c;
--------------------------------------------------------------------
--- H2.h
--------------------------------------------------------------------
#include "H1.h"

class T2
{
<...>
void method(T1c);
}
--------------------------------------------------------------------

Is it possible to resolve the conflict described? Or should I find a
way to avoid this kind of cross calls?

Thanks for any help :)

Jul 11 '07 #1
6 1651
Ma***************@gmail.com wrote:
I have an-easy-to-resolve (I am sure but I am obviously unable to
figure the answer out) problem for C++ gurus.

Here's the situation I have fallen into...

2 header files: H1.h & H2.h
--------------------------------------------------------------------
--- H1.h
--------------------------------------------------------------------
#include "H2.h" // <------ error at compilation (unknown type:
T1c in the T2),
// without the #include: unknown
type T2 in the T11
class T11
{
<...>
T2 method();
Change to

class T2 method();
}

template <typename Tclass T12 :
: T11
{
<...>
}

typedef T1<charT1c;
--------------------------------------------------------------------
--- H2.h
--------------------------------------------------------------------
#include "H1.h"

class T2
{
<...>
void method(T1c);
Change to

void method(class T1c);
}
--------------------------------------------------------------------

Is it possible to resolve the conflict described? Or should I find a
way to avoid this kind of cross calls?
You don't have to avoid them. Read about forward declarations.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jul 11 '07 #2
I have replaced
void method(T1c);
by
void method(T1<char>);

Is it a good decision?

Jul 11 '07 #3
Ma***************@gmail.com wrote:
I have replaced
void method(T1c);
by
void method(T1<char>);

Is it a good decision?
Any decision that moves you closer to your goal is good.
Jul 11 '07 #4
On 11 , 15:11, "Victor Bazarov" <v.Abaza...@comAcast.netwrote:
Mail.To.Nathan...@gmail.com wrote:
I have replaced
void method(T1c);
by
void method(T1<char>);
Is it a good decision?

Any decision that moves you closer to your goal is good.
It could be an "it-works-but-you-should-never-do-this" solution :)

Anyway, :D

Jul 11 '07 #5
Ma***************@gmail.com wrote:
On 11 , 15:11, "Victor Bazarov" <v.Abaza...@comAcast.netwrote:
>Mail.To.Nathan...@gmail.com wrote:
>>I have replaced
void method(T1c);
by
void method(T1<char>);
>>Is it a good decision?

Any decision that moves you closer to your goal is good.

It could be an "it-works-but-you-should-never-do-this" solution :)
OK, I took another look and think that your solution does not really
fall into that category. However, there is something to be said, of
course. 'T1c' is a typedef in the header you didn't (or couldn't)
include. Why is it a typedef? At some point the decision was made
to have a typedef instead of forcing the user type 'T1<char>'. Was
that to save typing or was there other reason? If it was to save
typing, replacing 'T1c' with 'T1<char>' in the declaration above is
perfectly OK. However, if it was because on some systems 'T1c' can
be something else (and not necessarily 'T1<char>'), and the choice
has to be governed by some #define or whatever other means, then
being explicit here may not be what you need. The latter case is,
admittedly, unlikely.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jul 11 '07 #6
It was only a user-confort choice allowing for shorter type names. So
everything seems OK now.

Thank you really very much for your help and attention.

Spasibo :)
On 11 , 16:02, "Victor Bazarov" <v.Abaza...@comAcast.netwrote:
Mail.To.Nathan...@gmail.com wrote:
On 11 , 15:11, "Victor Bazarov" <v.Abaza...@comAcast.netwrote:
Mail.To.Nathan...@gmail.com wrote:
I have replaced
void method(T1c);
by
void method(T1<char>);
>Is it a good decision?
Any decision that moves you closer to your goal is good.
It could be an "it-works-but-you-should-never-do-this" solution :)

OK, I took another look and think that your solution does not really
fall into that category. However, there is something to be said, of
course. 'T1c' is a typedef in the header you didn't (or couldn't)
include. Why is it a typedef? At some point the decision was made
to have a typedef instead of forcing the user type 'T1<char>'. Was
that to save typing or was there other reason? If it was to save
typing, replacing 'T1c' with 'T1<char>' in the declaration above is
perfectly OK. However, if it was because on some systems 'T1c' can
be something else (and not necessarily 'T1<char>'), and the choice
has to be governed by some #define or whatever other means, then
being explicit here may not be what you need. The latter case is,
admittedly, unlikely.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask

Jul 11 '07 #7

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

Similar topics

15
by: Roedy Green | last post by:
In a spreadsheet you can arrange that column headers are always visible no matter how much your scroll the table itself. What is the best way to get this effect in CSS?. Does it require frames or...
3
by: sam | last post by:
Hello Group, Havent had luck posting it to microsoft.public.dotnet.framework.aspnet.datagridcontrol group. Excuse me for the cross posting. I have a datagrid which needs to be split into multiple...
71
by: Christopher Benson-Manica | last post by:
At what point was the .h dropped from the STL headers? I just had a discussion yesterday with my boss, who said he wanted .h on all the STL includes, despite me protesting that it was not...
15
by: Dave | last post by:
Hello NG, It is well known that memory-allocating definitions should not be put in a header file. I believe, however, that this does not apply to const definitions. For example: #ifndef...
1
by: John M | last post by:
I know that you can make a cross tab query and get the fields as headers but it makes the form or datasheet unusable, ie cant add any data in the resulting fields. Is there a way of making a table...
23
by: Jeff Rodriguez | last post by:
Here's what I want do: Have a main daemon which starts up several threads in a Boss-Queue structure. From those threads, I want them all to sit and watch a queue. Once an entry goes into the...
4
by: cooltech77 | last post by:
Hi, I am trying to build the following functionality in the datagrid. I have a lot of columns in the datagrid which are being populated from the database and the user needs to scroll...
1
by: evanpmeth | last post by:
I am currently working a program that was intended to be purely JS and AJAX. Due to the cross domain access problems i have defaulted to a language I enjoy more, Python. My project consists of a...
6
by: Maart_newbie | last post by:
Hi all, Can anyone tell me how I can include one header Form1.h into another header Form2.h and the other way around without evolving into compile errors? Both headers contain only one class in...
2
by: ADT_CLONE | last post by:
I am having trouble with headers at the moment. Here is the code for a start: body.h: #pragma once #ifndef BODY_H #define BODY_H
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.