Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



Headers and Sources in C++

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 19-02-2009
Member
 
Join Date: Dec 2008
Posts: 70
Headers and Sources in C++
  

hi,
If I have any C + + source code from the Internet to view, then there's a *. cpp and *. h file with the same name.Traditionally, it is so that in the header files, the prototypes of the functions and features and elements in the same source files, the declarations are correct?Suppose that all files belong to a project (in my Dev-Cpp), the cpp file, where the main () function is available, but all must include the header files (# include "xyz.h")? But what with the same name *. cpp files.I did as an abstract class in a header "abstract.h" should be a class SubAbstract that inherits the abstract class and what in "subabstract.h" should be, the declaration of the element functions come in "subabstract.cpp "and then somewhere in the" main.cpp ".can any one give me the explanation?Thanks in advance for your help.

Reply With Quote
  #2  
Old 19-02-2009
Member
 
Join Date: Apr 2008
Posts: 1,993
Re: Headers and Sources in C++

It normally uses headers in this framework

Code:
# ifndef EXAMPLE_HEADER_H  
  # define EXAMPLE_HEADER_H  

  / / ...  Header Code ... 

  # endif
But here EXAMPLE_HEADER_H for a clear definition per header.By this will prevent the header in the same translation unit is inserted twice, which is inevitably would lead to problems.
Reply With Quote
  #3  
Old 19-02-2009
Member
 
Join Date: Oct 2005
Posts: 2,385
Re: Headers and Sources in C++

The compiler processes all source files from a project individually. it is not necessarily know how a called function is implemented (definition) is, he must be the only correct way in which they are familiar call. Therefore, the "notice" (declaration) in a header file included. The compiled files,are not really executable, there is usually still a lot of placeholder for function calls and variables from other sources. From the compiled files is an executable file, then the linker compound.
Reply With Quote
  #4  
Old 19-02-2009
Member
 
Join Date: May 2008
Posts: 2,001
Re: Headers and Sources in C++

Do you mean any constants? If yes then it should be included in the header / source file in which you use this. Do you have the header definition, as described Code has included them in the header file.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Headers and Sources in C++"
Thread Thread Starter Forum Replies Last Post
Regex for defining headers TechGate Software Development 5 16-02-2010 05:00 AM
HTTP headers Dharamsi Software Development 5 02-02-2010 06:23 PM
PHP Headers already sent by Hattie Tips & Tweaks 0 19-12-2008 05:10 PM
Sources Android available to all Denisez Portable Devices 0 22-10-2008 05:08 PM
Gmail won't download headers! rEDNESS Windows Vista Mail 3 27-05-2008 12:51 AM


All times are GMT +5.5. The time now is 03:48 AM.