I am taking apart some old code and breaking it up into header and cpp files from my old days when I would code in one ugly block.
Creating a repository to hold different data structures and commonly used files of mine, using as much inheritance as possible.
When creating my base Node class and it's children ie(treeNode, listNode) I am having an issue returning the base left and right pointers, im sure it's something simple and stupid but this has had me triped up for about 30 minutes so I figured I would ask.
Errors:Error 1 error C2440: 'return' : cannot convert from 'Node *' to 'treeNode *'
Error 3 error C2440: 'return' : cannot convert from 'Node *' to 'dictionaryNode *'
Node:HeaderCODE
#include <iostream>
#include <string>
#include <istream>
using namespace std;
#ifndef NODE
#define NODE
class Node
{
public:
Node *Left, *Right;
Node();
void setLeft(Node *n);
void setRight(Node *n);
Node * getLeft();
Node * getRight();
};
#endif
Node:.cppCODE
#include <iostream>
#include <string>
#include <fstream>
#include "Node.h"
using namespace std;
Node::Node()
{
Left=NULL;
Right=NULL;
}
void Node::setLeft(Node *n)
{
Left = n;
}
void Node::setRight(Node *n)
{
Right = n;
}
Node * Node::getLeft()
{
return Left;
}
Node * Node::getRight()
{
return Right;
}
TreeNode:HeaderCODE
#include <iostream>
#include <string>
#include <istream>
#include "Node.h"
using namespace std;
#ifndef TREENODE
#define TREENODE
class treeNode : public Node
{
public:
treeNode *Parent;
treeNode();
void setParent(treeNode *n);
treeNode * getParent();
};
#endif
TreeNode:.cppCODE
#include <iostream>
#include <string>
#include <fstream>
#include "treeNode.h"
using namespace std;
treeNode::treeNode(int Shares, double Price):Node()
{
Parent = NULL;
}
treeNode * treeNode::getParent()
{
return Parent;
}
void treeNode::setParent(treeNode *n)
{
Parent = n;
}
Same problem different child for all when interacting with the Left and Right base pointers.
Any ideas would be appreciated.
I have been using the online code communities for a while, and this site has been the one I have found the most helpful so I finally decided to register and get a little involved.
Thanks again,
Mike
This post has been edited by MikeRaines: 30 Oct, 2007 - 08:39 PM