Thread: header file help

  1. #1
    Unregistered
    Guest

    header file help

    I can't seem to get a simple header file to work, when my teacher does it, it seems to work fine. Here is a short piece of code that I can't get to compile.

    ------------------------
    //defines.h
    #ifndef DEFINES_H
    #define DEFINES_H

    void foo();
    void bar();

    int nNum;

    #endif
    -------------------------

    -------------------------
    //driver.cpp
    #include <iostream>
    #include "defines.h"

    using namespace std;

    main()
    {
    foo();
    bar();

    cout << nNum << endl;

    return (0);
    }
    -------------------------

    ________________
    //process.cpp
    #include <iostream>
    #include "defines.h"

    using namespace std;

    void foo()
    {
    nNum = 5;

    return;
    }

    void bar()
    {
    nNum += 1;

    return;
    }
    ---------------------------

    Any help would be great, thanks

  2. #2
    kmaz
    Guest

    Header Files

    Don't declare the variables in the header file. Thats just wrong.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. 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
  2. Replies: 30
    Last Post: 06-19-2006, 12:35 AM
  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