Chcel by som trosku pomoct s tým to hadze to že ...
Kód:
Error 1 error LNK2019: unresolved external symbol "public: __thiscall TreeNode::TreeNode(void)" (??0TreeNode@@QAE@XZ) referenced in function "public: __thiscall Or::Or(class TreeNode,class TreeNode)" (??0Or@@QAE@VTreeNode@@0@Z)
keby ste boli taký dobry a vedeli pomocť
treenode.cpp
Kód:
#include <iostream>
#include "TreeNode.h"
#include "Table.h"
using namespace std;
TreeNode::TreeNode(TreeNode* Left, TreeNode* Right)
{
LeftPtr = Left;
RightPtr = Right;
}
Or::Or(TreeNode *Left,TreeNode *Right)
{
LeftPtr = Left;
RightPtr = Right;
}
Not::Not(TreeNode* Left,TreeNode* Right)
{
LeftPtr = Left;
RightPtr = NULL;
}
Xor::Xor(TreeNode* Left,TreeNode* Right)
{
LeftPtr = Left;
RightPtr = Right;
}
And::And(TreeNode* Left,TreeNode* Right)
{
LeftPtr = Left;
RightPtr = Right;
}
Variable::Variable(int Index, Table T)
{
Value = T.GetVariableValue(Index);
};
bool Variable::Evaluate()
{
return Value;
};
bool And::Evaluate()
{
return (LeftPtr->Evaluate() && RightPtr->Evaluate());
};
bool Or::Evaluate()
{
return (LeftPtr->Evaluate() || RightPtr->Evaluate());
};
bool Xor::Evaluate()
{
return (LeftPtr->Evaluate() ^ RightPtr->Evaluate());
};
bool Not::Evaluate()
{
return (!LeftPtr->Evaluate());
};
treenode.h
#ifndef __TREENODE_H__
#define __TREENODE_H__
#include <iostream>
#include "Table.h"
using namespace std;
class TreeNode
{
protected:
TreeNode* LeftPtr;
TreeNode* RightPtr;
public:
TreeNode();
TreeNode(TreeNode*, TreeNode*);
virtual ~TreeNode(void)
{
delete [] LeftPtr;
delete [] RightPtr;
}
virtual bool Evaluate(void)
{
return false;
}
};
class Variable :public TreeNode
{
public:
Variable(int, Table);
bool Evaluate();
virtual ~Variable()
{
delete [] LeftPtr;
delete [] RightPtr;
}
private:
bool Value;
};
class Or : public TreeNode
{
public:
Or(TreeNode* ,TreeNode* );
virtual ~Or()
{
delete [] LeftPtr;
delete [] RightPtr;
};
bool Evaluate();
private:
};
class Xor : public TreeNode
{
public:
Xor(TreeNode* ,TreeNode* );
virtual ~Xor()
{
delete [] LeftPtr;
delete [] RightPtr;
};
bool Evaluate();
private:
};
class Not : virtual public TreeNode
{
public:
Not(TreeNode *,TreeNode *);
virtual ~Not()
{
delete [] LeftPtr;
delete [] RightPtr;
};
bool Evaluate();
private:
};
class And : public TreeNode
{
public:
And(TreeNode *, TreeNode *);
virtual ~And()
{
delete [] LeftPtr;
delete [] RightPtr;
};
bool Evaluate();
private:
};
#endif
main
#include<iostream>
#include"Table.h"
#include"TreeNode.h"
const int N = 3;
void main()
{
Table *table = new Table(N);
table->SetVariable(0,true);
table->SetVariable(1,true);
table->SetVariable(2,true);
TreeNode* root = new Or (new Variable (0,*table),new Variable (1,*table));
}
// pridané po 1 hodine 17 minútach od posledného príspevku
Viem že je už vela hodín ale ste moja posledna nádej.. zajtra to musí ísť..:/ prosím o pomoc
// Premenovane + kod patri do code. Zacni pisat ako clovek, neda sa to citat. Ďuri