Hello, I'm trying to learn how to do basic modules in c++ but seems impossible to me. i followed some books but at last always the compiler can't reach the functions in the module and it's frustrating, please if somebody can explain me what i'm doing bad I will be greatful.
(My Ide is codeblocks and I use gcc-4.7.3-r1)
following some books, first I declare the interface cab.h
interface
Código:
/* cab.h
Interface file */
void recogeValores();
Second, I build the implementation "cab.cpp"
Código:
/* cab.cpp
implement functions declared on interface */
#include "cab.h" //<--------------- Including the interface
#include <iostream>
#include "cab.h" //<--------------- Including the interface
#include <iostream>
using namespace std;
int main (){
recogeValores();
}
According to the books all will be fine. i did include the calls to the interface on main and implementation, however when i try to compile, g++ says: reference to recogeValores() undefined
On the other hand, if I delete the #include "cab.h" on the implementation, and add #include "cab.cpp" at the begining of the interface file, the program compile and works, but I think that this isn't the correct way to write the programs.
Please can anybody show me the correct way to write the program and solve the issue?
Thans in advance
> and add #include "cab.cpp" at the begining of the interface file,
> the program compile and works, but I think that this isn't the correct way to write the programs. http://www.cplusplus.com/forum/beginner/34484/#msg186401
The problem was mine! Sorry, I forgot put a tick on Debug & Realase inside "add file to active project on build targets" for the implementation and declaration files