Re: [Dev-C++] linking .h file and .cpp file
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Vlada D. <dj...@im...> - 2004-05-21 10:16:28
|
----- Original Message -----
From: "casper" <oz...@op...>
To: <dev...@li...>
Sent: Friday, May 21, 2004 11:15 AM
Subject: [Dev-C++] linking .h file and .cpp file
> Hi,
>
> I have a file with .h extension which includes my main program.
I
> have put
>
> #include "logfuncion.cpp"
>
> In the .h extension file. And inside the .cpp file I have put
the
> function definitions.
>
> Both files are in the same directory, but the .h file failed to compile
> because of the error
>
> Undefined "logfuncion.cpp"
>
> How could I solve the problem?
>
> Thanks in advance.
>
It should be the other way around. Your function declarations should go in
.h file, and their definitions in .cpp.
For example:
---myheader.h---
class Myclass{
public void f();
public int g(int x);
}
--end of myheader.h---
And in mymain.cpp you should do:
----mymain.cpp------
#include <myheader.h>
void Myclass::f(){
//define function
}
int Myclass::g(int x){
//define function
}
----end mymain.cpp----
|