I have a .h file, a .cpp implementation file, and a .cpp main. My implementation includes the .h file, and my .cpp main includes the .h file. all files are in the same directory. when i compile my main, i get errors of "undefined function xxxxxx" for each function in my .h file. What am i doing wrong?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
----------------------------------------------------------
where am I including/not including files? also, can I do this without making a project? if not, which project should i choose (windows exe, empty project, etc)? I've never used project before. thanks.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You have to have both of your .cpp files in the project (if you haven't created a project yet, do so). That way Dev knows to compile them both, instead of just the one you're working on.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have a .h file, a .cpp implementation file, and a .cpp main. My implementation includes the .h file, and my .cpp main includes the .h file. all files are in the same directory. when i compile my main, i get errors of "undefined function xxxxxx" for each function in my .h file. What am i doing wrong?
are you linking against the cpp implementation file?
From what you say it looks like you are just including the header file.
Try the following command:
gcc -o main.exe main.cpp otherfile.cpp
see which messages are printed.
//.h file
#ifndef circle_h
#define circle_h
void printfunction(double myint);
#endif
//.cpp file
#include "circle.h"
#include <iostream.h>
void printfunction(double myint)
{
cout<<"test"<<endl;
}
//driver
#include <iostream.h>
#include "circle.h"
int main()
{
printfunction;
return 0;
}
----------------------------------------------------------
where am I including/not including files? also, can I do this without making a project? if not, which project should i choose (windows exe, empty project, etc)? I've never used project before. thanks.
You have to have both of your .cpp files in the project (if you haven't created a project yet, do so). That way Dev knows to compile them both, instead of just the one you're working on.
The project you are building in a console.
Curtis