I have absolutely no clue why I'm getting these errors. My code is something like this:
type.h
typedef struct {
int* myInt;
} myType;
class.h
#ifndef myClass
#define myClass
#include "type.h"
void makeMyType( myType& t );
void deleteMyType ( myType& t );
#endif
class.C
#include "type.h"
makeMyType( myType& t ) {
t.myInt = (int*) malloc (sizeof(int));
t.myInt = 0;
}
deleteMyType ( myType& t ) {
free (t);
}
useType.C
#include "type.h"
#include "class.h"
int main {
myType t;
makeMyType (t);
deleteMyType (t);
return 0;
}
Then the compiler gives me the following:
error: identifier "makeMyType" is undefined
error: identifier "deleteMyType" is undefined
What could be causing this error? How can I fix it?
These 2 function prototypes are declared in
class.h
and not intype.h
and you are includingtype.h
in yourclass.c
file which is why you are seeing this issue.class.h
should be included inclass.c