Results 1 to 4 of 4

Thread: Headers and Sources in C++

  1. #1
    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.

  2. #2
    Join Date
    Apr 2008
    Posts
    2,010

    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.

  3. #3
    Join Date
    Oct 2005
    Posts
    2,394

    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.

  4. #4
    Join Date
    May 2008
    Posts
    2,015

    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.

Similar Threads

  1. Regex for defining headers
    By TechGate in forum Software Development
    Replies: 5
    Last Post: 16-02-2010, 05:00 AM
  2. HTTP headers
    By Dharamsi in forum Software Development
    Replies: 5
    Last Post: 02-02-2010, 06:23 PM
  3. PHP Headers already sent by
    By Hattie in forum Tips & Tweaks
    Replies: 0
    Last Post: 19-12-2008, 05:10 PM
  4. Sources Android available to all
    By Denisez in forum Portable Devices
    Replies: 0
    Last Post: 22-10-2008, 05:08 PM
  5. Gmail won't download headers!
    By rEDNESS in forum Windows Vista Mail
    Replies: 3
    Last Post: 27-05-2008, 12:51 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •