Errr...
I'm using DJGPP (gcc) with the RHIDE editor for compiling. However, whenever I try to use classes I get multiple definition errors...
For example (several imaginary files):
File useless.h:
#ifndef USELESS_INIT
#define USELESS_INIT
class useless
{
public:
useless();
void aFunction(int);
private:
int aVar;
};
#endif
File useless.cpp:
#include "useless.h"
useless::useless()
{
aVar = 0;
}
void useless::aFunction(int newVal);
{
aVar = newVal;
return;
}
File example.cpp:
#include "someclass.h"
int main()
{
useless anObject;
anObject.aFunction(3);
return 0;
}
Pretty useless class mmm? ^_^
Each file will compile fine, but when I try to link the source files together, I get an error something like:
quote:
Error: useless.o: In function 'useless::useless(void)':
useless.cpp(3) Error: multiple definition of 'useless::useless(void)'
o:useless.cpp(3) Error: first defined here
for _every_ function in _every_ class. o_O What confuses me is that they compile and link fine with Bloodshed Dev-C++, so... What am I doing wrong? Any help would be greatly appreciated.
Eck! Sorry for the long winded post.. Thanks in advance.
Edited by - fairie on July 18, 2001 2:46:46 AM