Thread: A major programming problem. pls help.

  1. #1
    Registered User
    Join Date
    Nov 2005
    Posts
    9

    A major programming problem. pls help.

    Hi,

    I have declared a number of .cpp file and their respective .hpp files.

    In actual fact, there is no object-oriented programming involved in my files. It is the typical C programming style except that I want to declare my variables anywhere within the function, thus I conveniently declare the files as .cpp.

    Now the problem is that when i try to include the header files, the compiler is unable to read the implementation of the function prototypes. Can anyone pls advise me on how i should go about fixing my messy codes?

    Currently, I just simply include the .cpp files in the main program file.

    I hope I have painted a clear picture of my problem.

    Thanks in advance!

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661

  3. #3
    ex-DECcie
    Join Date
    Dec 2005
    Posts
    125
    As an alternative, if your compiler provides support for the C99 standard, you could call your files .c and .h and compile with the support for C99 turned on.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    > Now the problem is that when i try to include the header files, the compiler is unable to read the implementation of the function
    There's no reason for it to - header files are for interfaces, not implementations.
    foo.h is the interface, and you #include "foo.h" when you need something in foo.cpp
    foo.cpp also has #include "foo.h", and actually implements the interface.

    You then compile with something like
    gcc main.cpp foo.cpp

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Bin packing problem....
    By 81N4RY_DR460N in forum C++ Programming
    Replies: 0
    Last Post: 08-01-2005, 05:20 AM
  2. Words and lines count problem
    By emo in forum C Programming
    Replies: 1
    Last Post: 07-12-2005, 03:36 PM
  3. half ADT (nested struct) problem...
    By CyC|OpS in forum C Programming
    Replies: 1
    Last Post: 10-26-2002, 08:37 AM
  4. binary tree problem - help needed
    By sanju in forum C Programming
    Replies: 4
    Last Post: 10-16-2002, 05:18 AM
  5. Spot the problem..a test question, pls help!
    By Unregistered in forum C++ Programming
    Replies: 10
    Last Post: 02-05-2002, 01:40 AM