Re: header file

From: Chris Mantoulidis (cmad_x_at_yahoo.com)
Date: 12/24/03


Date: 23 Dec 2003 23:23:00 -0800

apt2003@columbia.edu (mescaline) wrote in message news:<e54f0744.0312231752.1c1bf04c@posting.google.com>...
> Hi I have the following doubt about header files --
> I have the foll. 3 files in a folder.
>
> File 1: one.cpp
> #include <hel.h>

#include "hel.h"

> #include <iostream>
> using namespace std;
>
> int main(){
> hello();
> return 0;
> }
>
>
> File 2: hel.h
> #ifndef HEL_H
> #define

it should be #define HEL_H

> void hello();
> #endif
>
> File 3: hel.cpp
> #include <hel.h>

#include "hel.h"

> void hello(){
> cout << "Hello" << endl;
> }
>
> --------------
> I just need the output Hello using this header file formatting. I have
> these three files in a folder. How should I compile these three files
> using g++? WHen I just try g++ one.cpp, I get the output: hel.h: No
> such file or directory
>
> Thanks
> m

Wrong way to compile them... Do:

g++ -c hel.cpp
g++ -c one.cpp
g++ -o one one.cpp

;) I suppose you are on Linux, that's why I add no extension to the
executable. You can change it if you want



Relevant Pages

  • Nested Union Structure and scope resolution operator
    ... using namespace std; //introduces namespace std ... I tried to compile the source using both C++ Builder and Metrowerks ...
    (alt.comp.lang.learn.c-cpp)
  • Re: STL on Solaris system
    ... I would like compile a little program in c++ ... using namespace std; ... test.cpp: In function 'int main': ... This is free software; see the source for copying conditions. ...
    (comp.unix.solaris)
  • Re: collect2: ld returned 8 exit status
    ... I'm trying to compile a short piece of code in C++: ... using namespace std; ... int main ... $ g++ test.cpp -o testcpp ...
    (comp.unix.aix)
  • Re: Unable to match function definition to an existing declaration
    ... > using namespace std; ... > int main ... and it can't compile it either. ... to submit a bug report for that, ...
    (microsoft.public.vc.language)
  • Re: C++ compile error
    ... > hello.C: In function `int main': ... +using namespace std; ... > complex language when I compile my first program. ... > This post may off topic of FreeBSD, ...
    (freebsd-questions)