Hi, I´m new to c++ and inheritance therefore I have a problem with this code. Please help :P
I want to create two classes ("leaf" and "internal") that inherit from "node". I removed everything from the code to reproduced the error.
When I call a function that uses "node" in "leaf.cpp" a link error occurs :S
The error is:
Linking...
leaf.obj : error LNK2019: unresolved external symbol "public: void __thiscall node::test(class node *)" (?test@node@@QAEXPAV1@@Z) referenced in function "public: void __thiscall leaf::test(class node *)" (?test@leaf@@QAEXPAVnode@@@Z)
C:\Documents and Settings\MiguelDeVezEmQuando\My Documents\Visual Studio 2005\Projects\tree\Debug\tree.exe : fatal error LNK1120: 1 unresolved externals
Build log was saved at "file://c:\Documents and Settings\MiguelDeVezEmQuando\My Documents\Visual Studio 2005\Projects\tree\tree\Debug\BuildLog.htm"
tree - 2 error(s), 0 warning(s)
I got three ".h"s
Node.h
Code:
#ifndef nodeH
#define nodeH
class node {
public:
node* k;
void test(node* in);
};
#endif
Leaf.h
Code:
#include "node.h"
#ifndef leafH
#define leafH
class leaf : public node {
public:
void test(node* in);
};
#endif
Internal.h
Code:
#include "node.h"
#ifndef internalH
#define internalH
class internal : public node{
public:
node* j;
void test(node* in);
};
#endif
And one CPP
Leaf.h
Code:
#include "leaf.h"
#ifndef leafCPP
#define leafCPP
void leaf::test(node* in)
{
in->test(in);
}
int main()
{
return 0;
}
#endif