Thread: Header file

  1. #1
    Registered User
    Join Date
    Mar 2010
    Posts
    94

    Header file

    Header file - Wikipedia, the free encyclopedia

    Search: "One drawback of this method is that the prototype must be present in all files that use the function. Another drawback is that if the return type or arguments of the function are changed, these prototypes will have to be updated. "

    I cannot understand this part... -> Another drawback is that if the return type or arguments of the function are changed, these prototypes will have to be updated.

    How prototypes will have to be updated??? PLEASE HELP...

  2. #2
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by c_lady View Post
    Header file - Wikipedia, the free encyclopedia

    Search: "One drawback of this method is that the prototype must be present in all files that use the function. Another drawback is that if the return type or arguments of the function are changed, these prototypes will have to be updated. "

    I cannot understand this part... -> Another drawback is that if the return type or arguments of the function are changed, these prototypes will have to be updated.

    How prototypes will have to be updated??? PLEASE HELP...
    Ok lets say you have a .h header file with the following...
    Code:
    int GatherIdeas(int a, int b, int c);
    and your code has the following...
    Code:
    int GatherIdeas(int a, int b, int c)
      { return (a * b) / c; }
    Now in the process of developing your code you discover you would be better off with a floating point value as a return... If you change the function in your code, you also have to change it in the header file. If you don't the compiler is going to give you errors about "redefinition of function" and such because it no longer knows which version to believe.

    Header files have their place. No complex project could be written without them... but function prototypes and function calls in your code do have to match.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Memory Leak in AppWizard-Generated Code
    By jrohde in forum Windows Programming
    Replies: 4
    Last Post: 05-19-2010, 04:24 PM
  2. Need Help Fixing My C Program. Deals with File I/O
    By Matus in forum C Programming
    Replies: 7
    Last Post: 04-29-2008, 07:51 PM
  3. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  4. Making a LIB file from a DEF file for a DLL
    By JMPACS in forum C++ Programming
    Replies: 0
    Last Post: 08-02-2003, 08:19 PM