Thread: So Now Im getting confused?!?!?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #8
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Big words.. scary
    I'll try to sum that up:

    Each .cpp file is compiled into a separate object file, so that only .cpp files that have been modified need to be re-compiled, to save time (and possibly gray hairs).

    If in the main cpp you want to use functions that are defined in other .cpp files, the compiler won't know what to do unless you tell it what parameters the function takes, and what it returns; you do this (tell the compiler the parameters and return type) by declaring the function 'prototype', like so:

    int someFunctionInAnotherCPPFile(int, char, char*, double);

    Do you remember what #include does? Basically, it just grabs whatever file you specify, and sticks it where you put the #include. That's why you put the function prototypes for .cpp files in headers, that way when you include the .h, it tells the compiler how to use the function in the other .cpp.

    When you split a class into a header and .cpp, basically you're doing the same thing... except with a class instead of a function.

    Then, you have the linker. The linker' job is to grab all the object files that the compiler made, and glue them together in a big .exe file, so that the functions are all together in a big happy family, and the main .cpp (not really a .cpp anymore, it's a .exe now) can use them all, based on the prototypes that you gave the compiler earlier.

    Hope this helps! I tried to get rid of all the confusing programming jargon that makes learning hard.
    Last edited by Hunter2; 03-04-2004 at 10:19 PM.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. New to C++ and confused by boolean and ifs and else
    By jconner in forum C++ Programming
    Replies: 10
    Last Post: 08-02-2006, 03:29 AM
  2. Confused
    By jeev2005 in forum C Programming
    Replies: 5
    Last Post: 06-01-2006, 02:04 PM
  3. Confused
    By (TNT) in forum C# Programming
    Replies: 1
    Last Post: 11-23-2005, 04:49 PM
  4. confused.. in selecting my line of deapth
    By jawwadalam in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 05-04-2003, 01:21 PM
  5. Extern Question, really confused
    By SourceCode in forum C Programming
    Replies: 10
    Last Post: 03-26-2003, 11:11 PM