There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
acer black screen blue screen boot bsod computer connection crash css dell display driver drivers email error excel explorer firefox firefox 3 game hard drive internet internet explorer itunes laptop lcd linux malware network networking nvidia outlook outlook 2003 outlook express partition printer problem ram router slow sound trojan usb video virus vista windows windows vista windows xp wireless
Software Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Software Development >
c++ files


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

Closed Thread
 
Thread Tools
redivivus's Avatar
Senior Member with 1,458 posts.
 
Join Date: Mar 2006
Experience: 8th hindu reincarnation -- Praise Allah
23-Oct-2006, 10:26 PM #1
c++ files
I need to know the difference between all these stupid file extensions.

.h
.hh
.c
.cc
.o

^-- These are the only ones that are annoying me so far. I am trying to include a class and it has a .cc and a .hh file. I believe the .hh file declares all the class functions and the .cc defines all the functions.

How do i include these into the original program? It gives me errors only when i try something like #include "filename.cc".
__________________
Knowing others is wisdom;
Knowing the self is enlightenment.
Mastering others requires force;
Mastering the self needs strength.
~ Lao Tzu

If the rest of them can survive only by destroying us, then why should we wish them to survive?
~ Ayn Rand
AGCurry's Avatar
Senior Member with 431 posts.
 
Join Date: Jun 2005
Location: Kansas City area
Experience: advanced but learning
24-Oct-2006, 10:21 AM #2
.h -- header file
.hh -- header file
.c -- C language source file
.cc -- C++ language source file
.o -- object file

To understand how all these files are related, you need to know that three processes are made on the files in order to take them from text files to an executable program.

1. Preprocessing recognizes and executes the preprocessor directives like #include, #define, #pragma, #ifdef, etc.. Files which are #included are read and inserted lexically into the files which #include them, and #defined symbols are replaced by their definitions.

2. Compilation reads the files resulting from preprocessing, checks syntax, and creates object files (.o).

3. Linking resolves external references within the .o files and creates an executable file.

Header files should not contain data or executable code.

.c and .cc files wil #include header files but should NOT #include other .c or .cc files.

.o files are binary files and can only be linked -- not included.

Hope this helps.
redivivus's Avatar
Senior Member with 1,458 posts.
 
Join Date: Mar 2006
Experience: 8th hindu reincarnation -- Praise Allah
24-Oct-2006, 01:24 PM #3
Thanks...

Just to follow up on that, if im trying to include a .hh and .cc file i would do something like this?

\\main file
#include "header.hh"
...

\\header.hh
#include "source.cc"
...

Is there something wrong with that it gives me an error. :-\
BanditFlyer's Avatar
Distinguished Member with 11,389 posts.
 
Join Date: Oct 2005
Location: BOT бaHДиT
Experience: It Depends
24-Oct-2006, 02:23 PM #4
I think comments are done with //, not \\

What errors do you get?
redivivus's Avatar
Senior Member with 1,458 posts.
 
Join Date: Mar 2006
Experience: 8th hindu reincarnation -- Praise Allah
24-Oct-2006, 02:30 PM #5
Quote:
Originally Posted by BanditFlyer
I think comments are done with //, not \\

What errors do you get?
Couldnt remember lol. And nor do i use them.

The compiler highlights the line #include "file.hh" and says something like Error in calling file, though im not sure exactly what it was... i remember that it told me basically nothing about the error. :-\
AGCurry's Avatar
Senior Member with 431 posts.
 
Join Date: Jun 2005
Location: Kansas City area
Experience: advanced but learning
24-Oct-2006, 03:43 PM #6
Quote:
Originally Posted by redivivus
Thanks...

Just to follow up on that, if im trying to include a .hh and .cc file i would do something like this?

\\main file
#include "header.hh"
...

\\header.hh
#include "source.cc"
...

Is there something wrong with that it gives me an error. :-\
YES, this is not correct. What you've coded above is a recursive include - file a includes file b which includes file a ...

Your source-code files - .c and .cc - will include .h and .hh files. Not vice versa.
redivivus's Avatar
Senior Member with 1,458 posts.
 
Join Date: Mar 2006
Experience: 8th hindu reincarnation -- Praise Allah
24-Oct-2006, 05:51 PM #7
Quote:
Originally Posted by AGCurry
YES, this is not correct. What you've coded above is a recursive include - file a includes file b which includes file a ...

Your source-code files - .c and .cc - will include .h and .hh files. Not vice versa.
Getting confused more now lol.

Is cc like cpp? Or am i right in thinking it is just an expansion of the individual header file?

And how do it include it in my MAIN program source code?
BanditFlyer's Avatar
Distinguished Member with 11,389 posts.
 
Join Date: Oct 2005
Location: BOT бaHДиT
Experience: It Depends
24-Oct-2006, 06:48 PM #8
cpp are the files you write, .cc are the libraries already written in c++.

What AGCurry was saying is that your code should look like this:
Quote:
Originally Posted by redivivus
\\main file
#include "source.cc"

...

\\source.cc
#include "header.hh"
...
Not like this:
Quote:
Originally Posted by redivivus
Thanks...

Just to follow up on that, if im trying to include a .hh and .cc file i would do something like this?

\\main file
#include "header.hh"
...

\\header.hh
#include "source.cc"
...

Is there something wrong with that it gives me an error. :-\
Closed Thread

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who help people like you solve computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 05:09 PM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.