class node
{
private:
int* value;
int* before, after;
public:
int Read();
bool Write(int);
int* Before();
int* After();
bool SetBefore();
bool SetAfter();
};
Now, when I try and do either of these, they get the error that follows it:
#include "header.h"
//Implementation of the node class.
int node::Read()
{
return 1;
}
/*
Compiling: main.cpp
Compiling: Structures.cpp
Linking console executable: bin\Release\Data Structures Thing.exe
obj\Release\Structures.o:Structures.cpp:(.text+0x0): multiple definition of `node::Read()'
obj\Release\main.o:main.cpp:(.text+0x0): first defined here
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
0 errors, 0 warnings
*/
#include "header.h"
//Implementation of the node class.
node::Read()
{
return 1;
}
/*
error: ISO C++ forbids declaration of `Read' with no type|
||=== Build finished: 1 errors, 0 warnings ===|
*/
Looking in the eBook I have, the first one should be correct, but I get a redefinition error. Any help? =/
But anyways...
You forgot conditional compilation to prevent headers from being included more than once. Also, you forgot the return value type in the implementation of node::Read on the second one.
George Gough