Can Header Files Include Each Other?

free web hosting
Open Discussion > CONTRIBUTE > Computers > Programming Languages > C/C++ Programming

Can Header Files Include Each Other?

kvarnerexpress
Or will it create a circular include problem? What do you do if you need them to, and forward class declarations won't work?

Forward class declarations only allow you to declare an instance of that class, but you can't access member functions, you have to include the header file.

So if you use MS Visual C++ .NET and the code is placed in the header files, then what is the solution? I have two classes(forms) that need to include each other but it's not working. When I try it it stops recognizing the classes and gives errors like, "missing storage-class or type sepcifiers"

I've also used about every combination of #ifndef, #define, #endif combo's I could think of. It's driving me crazy!


Thanks for any help I might possibly get.

Reply

fffanatics
No circular classes do not include the header files in each other's header. Instead, in the main or whatever part of the program uses the class that includes another class, you would include both files. Then in the two class files you just would have class Class1; Class2 {...}; and then in the second class you would do class Class2; Class1 {...}; Let me know if this makes sense becuase if not i will include an example that i have used in a class of mine last semester. Just PM or post a reply

Reply

switch
just my two cents worth, but maybe you should take the stuff you need for both classes out of their respective header files and put them in a single header file. sort of like a kind of factorisation.

for example:

CODE
//class1.h
class myFirstClass
{
   //functions, variables etc
}

//class2.h
class mySecondClass
{
   //more functions variables etc
}


becomes

CODE
//myClasses.h
class myFirstClass {...};
class mySecondClass {...};


then, if myFirstClass needs to reference mySecondClass, i think you can add this line above the myFirstClass definition:
CODE
class mySecondClass;


hope this works / helps. good luck.

oh and just out of curiousity, if you wouldn't mind posting that example fffantics, i had a bit of trouble understanding your last post but it seems like its good stuff. thanks! biggrin.gif

 

 

 


Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.

Similar Topics

Keywords : header, files, include

  1. Deny Or Grant Users Access To Files Of Choice (vista)
    Uses Bat Files To Deny Or Grant People Access To Files (3)
  2. X Files: I Want To Believe!
    (2)
    I am a big fan of X Files (the D drives on both my desktop and my laptop are called X Files in
    it's honor /biggrin.gif" style="vertical-align:middle" emoid=":D" border="0" alt="biggrin.gif"
    /> ) so there was no way I'd miss it. I know it is a bit late, but the movie had it's
    opening a week ago in my country and I didn't want to simply download it. So here we go... X
    Files: I Want To Believe is a bit odd for the usual X Files topic - UFO, aliens... Not odd, but
    different! I knew that before viewing the movie and I was still disappointed at the end. ....
  3. How To Create Pdf Files Using Free Tool
    Introduction to use a free tool to create PDF file (0)
    Now, that you don't need to have expensive software like Acrobat to create PDF. All you need is
    Microsoft Office and a software name doPDF. You can download the freeware from
    http://www.dopdf.com/download.php After downloading dopdf.exe, follow the instruction below 1.
    Double click to install it, as display at image 1.jpg, choose a language and click OK 2. You will
    see 2.jpg click next 3. Click I accept the agreement see 3.jpg, click next 4. Now you will see
    4.jpg, select the folder to install it and click next 5. When seeing 5.jpg, This is the folder group
    in Star....
  4. Clearing Your Ie Tif
    Clear your Temporary Internet Files on IE (0)
    -Welcome to: Clearing your Internet Explorer Temporary Internet Files Tutorial-!
    Attention!: As some of the members on here may know, it is possible to clear your Internet
    Explorer Temporary Files. I have searched this entire Tutorials subforum to find a topic already
    made, and I have found nothing. This tutorial I did NOT find this on Google, or any other search
    engine. I always find this out for myself. Lets start: Ok, first we open up Internet Explorer,
    then we click "Tools"...then we click on "Internet Options...". On the Main page "Gener....
  5. How To Download Any Flv Files From Any Sites
    (6)
    Now you can download any flv files from any websites!! People often know how to download
    youtubes clip, but not from other sites. In this tutorial you will need a tool name Moyea FLV
    Downloader, it is free and you can download it at http://www.flvsoft.com/download_flv/ This is
    the best tool i have meet up with to download flv files in any site. Since it can detect flv files,
    and list it, you can download it as you want, so no more favourite clips goes away from your sight
    and now you have it on your own hard drive! 1. Run moyea flv downloader see 1.jpg 2.....
  6. Panasonic Lumix - Problems With Movie Files
    troubles managing (renaming, moving, deleting) movie files from the ca (0)
    I've recently bought a Panasonic Lumix TZ3, the one with a wideangle to telephoto lens (10x zoom
    from 28mm to 280mm equivalent) and I am very satisfied with the overall performance. Obviously I
    didn't buy the camera because of the movie features but occasionally I do take some short clip
    or use the "picture with audio" to comment on a photo, these functions are pretty easy to use and
    the quality of the video is reasonable. The movie files (or the audio attached to a picture) get
    saved in Jpeg Motion Picture format, generating a .MOV file which appears on the me....
  7. Flash Header Edit?
    flash header edit (2)
    Can someone help me edit a flash header from a template. I can figure out MX 2004. I am a novice web
    designer at best and need some help editing this header. Thanks so much ....
  8. Firefox Temporary Media Files
    Where are they stored? (0)
    Sometimes when I view video tutorials online and I want get pleased with the flash or mp4 I will be
    viewing online. When I try to seach for the temporary file stored by Firefox so that I can save it
    in another drive I fail to find it. Does anyone know where these files are stored and which format
    they will be in? One day I opened the folder: CODE C:\Documents and
    Settings\Rare\Local Settings\Application
    Data\Mozilla\Firefox\Profiles6qbhaqp.default\Cache and found a lot of files
    without extentions. Could these be the ....
  9. Lan Surfer In Linux
    GUI software to view other's shared files (2)
    I have been using LAN surfer and Network scanner in Windows , These software's are used
    to scan the LAN over a given range of IP addresses and then display the folders shared by each
    computer available on LAN in the specified range... now i have switched to Linux... Can you tell me
    any GUI software which would do this task in Linux ubuntu 7.04. I tried nmap but i did not
    find it that useful...i think it does only port scanning and stuff but does not display the files
    shared... but i am not sure..tell me if it can be used and how... I also installed s....
  10. Browse System Files In The Browser...
    (2)
    Hi all Trap 17 people... I am not sure if you are already aware of this fine piece of information,
    But definitely a must know feature... Browsing your system files in your browser. For more visit the
    below link http://varalu.blogspot.com/2008/07/browsin...in-firefox.html You can use this feature
    to do so many stuffs... pretty much useful for addon developers. /smile.gif"
    style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" />....
  11. Auto-upload Files With Filezilla And Autohotkey
    (0)
    If your web host only allows FTP access and not shell access then you have to edit files locally and
    then upload them. If you are debugging your website that means making a lot of changes to a file or
    files and lots of manual uploads after each change to a file. FileZilla works great to upload and
    download files to a remote FTP site and it even allows you to set a default editor so you can right
    click on a remote file and click view/edit. It then downloads the file to a temporary directory and
    monitors any changes made to the file. When it detects that you have saved the....
  12. How Can You Get Audio Files From Itunes Videos?
    (1)
    I need some help. How can you get audio files from iTunes videos? iTunes videos don't import
    into Windows Movie Maker so I don't know how. Is there a way to convert iTunes video files to
    kinds that are supported by Windows Movie Maker? Thanks in advance for help. /smile.gif"
    style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" />....
  13. Naming Web Page Files
    Which way you like- MyPage.html or my-page.html or my_page.html (9)
    Everybody talks about meta tags, keywords, good title names and how they can increase page rankings,
    etc. But I was wondering whether the page name itself holds any value in indexing. Yes, I am
    talking about the web page file names (some-thing.html) NOT the one which you put in title tags. I
    am going to express my views and want to know what you think is correct. I have seen pages named in
    various ways like these: 1) my_web_page.html 2) DoYouLikeMyPage.html 3) hey-see-my-webpage.html (I
    think this way is more appropriate) 4) this.is.a.page.html (somewhat confusing) ....
  14. Audio Files?
    (5)
    I need some help. Is it possible to get audio files off of sites? Like IMEEM and YouTube. I know the
    whole http://www.file2hd.com thing. It doesn't always work though. Are there other ways? Is
    there a way people hack audio files off of sites? NOTE: I DO NOT WANT DO THIS! I merely want to
    know so that I can protect my sites from it. Thanks.....
  15. Jar Executable Files
    (3)
    I have been supplied with a digital log book for use this semester and it comes in the form of a
    .jar file and a .mdb file. I tried running it on my mac but it crashes every time but it seems to
    run perfectly on windows xp. Does anyone have any ideas why? I thought .jar files would be
    computable on any platform. ....
  16. Best Way To Transfer Files
    I just bought a laptop (6)
    Hi there guys, I just bought a brand new Dell Inspiron laptop for $729.99. It has a
    processing speed of 2.0ghz, 3GB RAM, and a 250gb hard drive. I'm really satisfied, especially
    with the wireless internet and the fact that I can carry my computer around with me, allowing you to
    use your computer in comfortable spots -- outside in the shade, on the train, or even in your bed
    where I'm using it write now as I type. If you didn't already guess, this is my first
    laptop. But I do have some issues. Does anyone happen to know an easy way to transfer some ....
  17. 1350 Great Free Logos (jpg + Psd)
    With both jpg and original psd files to edit (8)
    1350 Great Free Logos (With both jpg and psd files)
    http://rapidshare.com/files/126291346/1346...Great.Logos.zip This is a great collection of
    logos, they are already made logos which you can use like that or just use to create other logos, do
    what you want, they are free, they came from free websites that give this logos for free and lot
    more, but i just took the good ones mainly. There is also a small collection of 100 logos inside
    the compressed file, which you can use to insert those graphics in your logo/design/web design
    projects, do what you want with them ....
  18. Debug Exe Files
    How to debug an exe file. (4)
    Think that we have written a program, and some codes are wrong. We can go back to compiler and
    change the code, and compile again. But I will show you how to correct our mistakes without using
    the compiler. Let's start: I have written a program in Delphi. Let's see my mistake. I
    have created a form like this. After this I wrote the codes in the Compare Button click as
    below. CODE 1.   procedure TForm1.ComparebuttonClick(Sender: TObject); 2.   var
    3.     a,b:integer; 4.   begin 5.     a := StrToInt(EditA.Text); 6.     b :....
  19. Converting Audio Files In Vista
    how do you do it? (7)
    Ok, so I have some .wav files that I'd like converted into .mp3. I knew how to do it in XP, but
    I can't find windows audio converter in Vista....does vista even have that, or is it under a new
    name? Also, is it possible to convert video files, like .flv into .avi?....
  20. Sharing Files And Printer Between Windows Vista And Xp
    Networking Problem (9)
    I have set up a wireless network between my two computers one vista and one XP I can access the
    shared files from the vista machine on the XP PC but I cannot access the shared files or printer
    which are on the XP PC via the vista one I don' think it is a firewall issue. Can anyone help
    please it is driving me mad?? /biggrin.gif" style="vertical-align:middle" emoid=":D" border="0"
    alt="biggrin.gif" />....
  21. Aef Forum Modifications [resolved]
    Header bar, Footer Bar and Styling them (3)
    Here are a couple of Tutorials I have posted on my AEF Forum hosted here at the Trap17. Since the
    Tutorials are already published, I will merely link to them. Header Bar Information :
    http://www.jlhaslip.trap17.com/aef103/index.php?tid=11 Footer Bar Information :
    http://www.jlhaslip.trap17.com/aef103/index.php?tid=10 Styling the Header/Footer Bar :
    http://www.jlhaslip.trap17.com/aef103/index.php?tid=16 The first two are about how to add some
    html code to the space reserved in the Forum layout for an optional Advertising spot. I adapted some
    code so that several ....
  22. How To Disable "show Hidden Files And Folders" In Folder Option
    (12)
    How to disable "Show hidden files and folders" in Folder Option As you know, you can hide files
    or folders in Microsoft Windows ( to hide a file or folder , right click on file or folder >select
    properties and then select Hide file) But if you open Folder Option and check "Show hidden files
    and folders " you can see hidden files. to disable "Show hidden files and folders" feature follow
    below steps : 1- Click start > Run > type regedit to run Windows Registry Editor. 2- Go to following
    address: QUOTE HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows/Current Versio....
  23. Eclipse Exporting .jar Files
    Could not find main class. Program will exit. (5)
    I need help! I've been using eclipse for a while making little applets, and now I've
    decided to look at some tutorials on how to make simple applications. I've found a pretty good
    tutorial that tells you how to make a helloWorld app with swt and jFace, and also has an example
    file explorer that you can make. They both work perfectly from inside eclipse, but when I try and
    export either one into a .jar file, they don't work anymore. It comes up with a message saying
    "Could not find main class. Program will exit." In the little wizard it has for....
  24. Informix To Sql Server (or How To Open .unl Files)
    how to import .unl files into SQL Server 2000 without Informix softwar (2)
    Does anyone know how to import .unl files into SQLServer 2000? My boss gave me this task to migrate
    an old database into SQLServer. I don't have informix installed since the files were sent to me
    via email. All files have .unl extension and I don't have a clue how to view them. I've
    tried opening them using excel but it can't be read. Does anyone know how to do this? Or at
    least know how to open/view the file using excel or any other program that could be easily migrated
    to sqlserver? Please, I need to migrate the files as soon as possible. Thanks....
  25. Strange .log Files On My Desktop
    (10)
    Since this morning, two new visitors has camped out on my desktop. One is lcapi0.log , & when you
    open it you get: QUOTE 19:50:36.703 F20:F24 WARN :: module=lcapi flavor=fre
    version=1.7.226.0 (RTC Version 4.3.5371.0) 19:50:38.109 F20:F24 INFO :: Initialize(0) 19:50:38.609
    F20:F24 INFO :: MUI not Enabled 19:50:44.625 F20:F24 INFO :: SetDeviceDisabled 0->0 19:50:44.656
    F20:F24 INFO :: SetDeviceDisabled 0->1 19:50:44.656 F20:F24 TRACE :: SetDevice 00000000->00000000
    19:50:44.656 F20:F24 INFO :: SetDeviceDisabled 0->0 19:50:44.656 F20:F24 TRACE :: SetDevic....
  26. Linux Question: Amarok And File Permissions
    please help, i can't get it to work with all music files (4)
    hey, i use to use Linux DC++ to download music from some hubs and i usually download it to
    /home/downloads/ and then i move the files to my collection on another HDD a sata one, on
    sda3/music/ but when i move the files using krushader root mode they become posessed by root and
    amarok can't play them displaying a locker on the file's icon. I tried to " chmod 774 music
    ", where music is my music directory, as root in konsole but no luck. What should i do to make a
    whole directory accessible from amarok as user?....
  27. Php Header Problem
    i always got header problem (11)
    i really hate the header function it always get an error saying ( cannot ------- headers already
    sent by----- ) and here's my error: Warning: session_start(): Cannot send session cookie -
    headers already sent by (output started at /home/adly3000/public_html/Mail/index.php:5) in
    /home/adly3000/public_html/Mail/index.php on line 81 Warning: session_start(): Cannot send session
    cache limiter - headers already sent (output started at /home/adly3000/public_html/Mail/index.php:5)
    in /home/adly3000/public_html/Mail/index.php on line 81 Warning: Cannot modify header ....
  28. The New And Very Good Free Host Server
    For upload/share files.www.rapidshare.se (13)
    Here it is: http://www.rapidshare.se/index.php Go check it out! I've heard good
    things about this free upload server.....
  29. Does Anyone Know How To Make Exe Files
    (19)
    Does anyone know any software for making exe files, I want to make simple programs not propper
    one's. Thanks.....
  30. Converting Video Files From One Format To Another
    help plz :) (6)
    hey i have learnt this nice way to open mov files in imageready and insert them in sigs,graphics and
    other stuff its really cool,this only works with .mov files and i really need to know if sumone here
    can do that,i need to change a wmv file into a .mov file so i cant add the movie to a sig,i have
    tried many video format conversion programs but they dont accept the mov format,the mov format is a
    quicktime video format,so anyone here know how to change a video file into a quicktime mov video
    format? thnx in advance....

    1. Looking for header, files, include

*RANDOM STUFF*





*SIMILAR VIDEOS*
Searching Video's for header, files, include

*MORE FROM TRAP17.COM*
Similar
Deny Or Grant Users Access To Files Of Choice (vista) - Uses Bat Files To Deny Or Grant People Access To Files
X Files: I Want To Believe!
How To Create Pdf Files Using Free Tool - Introduction to use a free tool to create PDF file
Clearing Your Ie Tif - Clear your Temporary Internet Files on IE
How To Download Any Flv Files From Any Sites
Panasonic Lumix - Problems With Movie Files - troubles managing (renaming, moving, deleting) movie files from the ca
Flash Header Edit? - flash header edit
Firefox Temporary Media Files - Where are they stored?
Lan Surfer In Linux - GUI software to view other's shared files
Browse System Files In The Browser...
Auto-upload Files With Filezilla And Autohotkey
How Can You Get Audio Files From Itunes Videos?
Naming Web Page Files - Which way you like- MyPage.html or my-page.html or my_page.html
Audio Files?
Jar Executable Files
Best Way To Transfer Files - I just bought a laptop
1350 Great Free Logos (jpg + Psd) - With both jpg and original psd files to edit
Debug Exe Files - How to debug an exe file.
Converting Audio Files In Vista - how do you do it?
Sharing Files And Printer Between Windows Vista And Xp - Networking Problem
Aef Forum Modifications [resolved] - Header bar, Footer Bar and Styling them
How To Disable "show Hidden Files And Folders" In Folder Option
Eclipse Exporting .jar Files - Could not find main class. Program will exit.
Informix To Sql Server (or How To Open .unl Files) - how to import .unl files into SQL Server 2000 without Informix softwar
Strange .log Files On My Desktop
Linux Question: Amarok And File Permissions - please help, i can't get it to work with all music files
Php Header Problem - i always got header problem
The New And Very Good Free Host Server - For upload/share files.www.rapidshare.se
Does Anyone Know How To Make Exe Files
Converting Video Files From One Format To Another - help plz :)
advertisement



Can Header Files Include Each Other?



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute your information that might help someone here.
Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE