"Jonathan Mcdougall" <jo***************@gmail.com>, haber iletisinde
sunlari yazdi:11**********************@g43g2000cwa.googleg roups.com...
Tayfun Özdemir wrote: "Jonathan Mcdougall" <jo***************@gmail.com>, haber iletisinde
sunlari
Please quote the message you are answering to.
[snipped badly quoted message]
http://web.presby.edu/~nnqadmin/nnq/nquote.html
Please, read it.
Thank you so much again Jonathan. I read all of the FAQ and I tried both
of
the suggestions on the FAQ. Unfortunately I could not solve my problem. I
will try to figure it out by trying something different.
Perhaps we could help you more if you provided the error messages
generated with the code you provided in your previous post.
Jonathan
I will change my newsreader very soon. Thanx for your reply.
I have changed my cpp and h files to their original.
I get following errors with different compilers:
////////////// .NET errors ////////////////
BTree error LNK2001: unresolved external symbol "public: virtual void
__thiscall TreeNode
<int,int,7>::Insert(int,int,int &,class TreeNode<int,int,7> * &,class
TreeNode<int,int,7> * &)" (?
Insert@?$TreeNode@HH$06@@UAEXHHAAHAAPAV1@1@Z)
BTree error LNK2019: unresolved external symbol "public: virtual void
__thiscall LeafNode
<int,int,7>::Insert(int,int,int &,class TreeNode<int,int,7> * &,class
TreeNode<int,int,7> * &)" (?
Insert@?$LeafNode@HH$06@@UAEXHHAAHAAPAV?$TreeNode@ HH$06@@1@Z) referenced in
function _main
BTree fatal error LNK1120: 2 unresolved externals
////////////// gcc errors////////////////
[shootgun@plesk Tree]$ gcc LeafNode.cpp main.cpp TreeNode.cpp -o h
/tmp/ccnze0Bu.o(.text+0x3a): In function `main':
: undefined reference to `LeafNode<int, int, 7>::Insert(int, int, int&,
TreeNode<int, int, 7>*&,
TreeNode<int, int, 7>*&)'
/tmp/ccnze0Bu.o(.gnu.linkonce.d._ZTV8LeafNodeIiiLi7EE+0 x8): undefined
reference to `LeafNode
<int, int, 7>::Insert(int, int, int&, TreeNode<int, int, 7>*&, TreeNode<int,
int, 7>*&)'
/tmp/ccnze0Bu.o(.gnu.linkonce.d._ZTV8TreeNodeIiiLi7EE+0 x8): undefined
reference to `TreeNode
<int, int, 7>::Insert(int, int, int&, TreeNode<int, int, 7>*&, TreeNode<int,
int, 7>*&)'
/tmp/ccnze0Bu.o(.gnu.linkonce.d._ZTI8TreeNodeIiiLi7EE+0 x0): undefined
reference to `vtable for
__cxxabiv1::__class_type_info'
/tmp/ccnze0Bu.o(.gnu.linkonce.d._ZTI8LeafNodeIiiLi7EE+0 x0): undefined
reference to `vtable for
__cxxabiv1::__si_class_type_info'
/tmp/ccnze0Bu.o(.eh_frame+0x11): undefined reference to
`__gxx_personality_v0'
collect2: ld returned 1 exit status
I paste my files again. I am not sure if the last ones are correct.
////////////// TreeNode.h ////////////////
#ifndef __TREE_NODE__
#define __TREE_NODE__
template <class KeyType, class ValType, int SIZE>
class TreeNode
{
public:
TreeNode() : nCount(0)
{};
virtual void Insert(KeyType Key, ValType Val, KeyType &ParentKey,
TreeNode<KeyType, ValType, SIZE> *&LeftChild,
TreeNode<KeyType, ValType, SIZE> *&RightChild);
protected:
int nCount;
KeyType e_Keys[SIZE];
TreeNode<KeyType, ValType, SIZE> *e_Childs[SIZE];
};
#endif
////////////// TreeNode.cpp ////////////////
#include "TreeNode.h"
template <class KeyType, class ValType, int SIZE>
void TreeNode<KeyType, ValType, SIZE>::Insert(KeyType Key, ValType Val,
KeyType &ParentKey,
TreeNode<KeyType, ValType, SIZE> *&LeftChild,
TreeNode<KeyType, ValType, SIZE> *&RightChild)
{
return;
}
////////////// LeafNode.h ////////////////
#include "TreeNode.h"
#ifndef __LEAF_NODE__
#define __LEAF_NODE__
template <class KeyType, class ValType, int SIZE>
class LeafNode : public TreeNode<KeyType, ValType, SIZE>
{
public:
LeafNode()
{
nCount = 0;
};
virtual void Insert(KeyType Key, ValType Val, KeyType &ParentKey,
TreeNode<KeyType, ValType, SIZE> *&LeftChild,
TreeNode<KeyType, ValType, SIZE> *&RightChild);
protected:
ValType e_Vals[SIZE];
};
#endif
////////////// LeafNode.cpp ////////////////
#include "LeafNode.h"
template <class KeyType, class ValType, int SIZE>
void LeafNode<KeyType, ValType, SIZE>::Insert(KeyType Key, ValType Val,
KeyType &ParentKey,
TreeNode<KeyType, ValType, SIZE> *&LeftChild,
TreeNode<KeyType, ValType, SIZE> *&RightChild)
{
int i = nCount;
// Shift values in the list by one until we find the spot
while (i != 0 && e_Keys[i - 1] > Key) {
e_Keys[i] = e_Keys[i - 1];
e_Vals[i] = e_Vals[i - 1];
i--;
}
// We are on the spot add new value to the list
e_Keys[i] = Key;
e_Vals[i] = Val;
nCount++;
// Check if we are full and are ready to split
if (nCount == SIZE) {
LeafNode<KeyType, ValType, SIZE> *Right = new LeafNode<KeyType,
ValType, SIZE>;
for (i = nCount / 2; i < nCount; i++) {
Right->e_Keys[i - nCount / 2] = e_Keys[i];
Right->e_Vals[i - nCount / 2] = e_Vals[i];
Right->nCount = i - nCount / 2 + 1;
}
}
return;
}
////////////// main.cpp ////////////////
#include <cstdio>
#include "LeafNode.h"
#include "TreeNode.h"
int main(int argc, char *argv[])
{
int a;
LeafNode<int, int, 7> TestNode;
TreeNode<int, int, 7> *e, *f;
TestNode.Insert(10, 10, a, e, f);
return 0;
}
Thank you so much for your answers and patience.
Sincerely,
Tayfun Ozdemir