Thread: header file help

  1. #1

    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.

    #ifndef DEFINES_H
    #define DEFINES_H

    void foo();
    void bar();

    int nNum;


    #include <iostream>
    #include "defines.h"

    using namespace std;


    cout << nNum << endl;

    return (0);

    #include <iostream>
    #include "defines.h"

    using namespace std;

    void foo()
    nNum = 5;


    void bar()
    nNum += 1;


    Any help would be great, thanks

  2. #2

    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