the WordNode h in BST.cpp: "WordNode" does not name a type
also in BST.cpp: "WordNode" undeclared, first use of this function
So, any advice? Sorry for the huge post, just wanted to make sure you can understand the problem. As it is, I'm lost.... I've included the WordNode header file, so why can't I create/use WordNode objects/methods (in BST)?
WordNode.h
Expand|Select|Wrap|Line Numbers
- #ifndef RANDOM
- #define RANDOM
- #include <string>
- #include <fstream>
- #include <fstream>
- #include <iostream>
- #include <dinput.h>
- #include "BST.h"
- using namespace std;
- class WordNode
- {
- public:
- WordNode(string name);
- string word;
- void getLeft( WordNode);
- void getRight (WordNode);
- WordNode *left;
- WordNode *right;
- bool hasLeft;
- bool hasRight;
- friend ostream& operator<<(ostream& os, const WordNode& wn);
- };
- #endif
- WordNode.cpp
- #include "WordNode.h"
- #include <string>
- #include <fstream>
- #include <string>
- #include <fstream>
- #include <vector>
- #include <iostream>
- #include <string>
- #include <stack>
- #include <queue>
- #include <dinput.h>
- #include "WordNode.h"
- using namespace std;
- WordNode::WordNode( string w)
- {
- word = w;
- }
- void WordNode::getLeft( WordNode lptr)
- {
- hasLeft = true;
- left = &lptr;
- }
- void WordNode::getRight( WordNode rptr)
- {
- hasRight = true;
- right = &rptr;
- }
- ostream& operator<<(ostream& os, const WordNode& wn)
- {
- os << wn.word;
- return os;
- };
BST.h
Expand|Select|Wrap|Line Numbers
- #ifndef RANDOM
- #define RANDOM
- #include <string>
- #include <fstream>
- #include <fstream>
- #include <iostream>
- #include <dinput.h>
- //#include "BST.h"
- #include "WordNode.h"
- using namespace std;
- class BST
- {
- public:
- BST();
- void insert();
- void print();
- WordNode h;
- //WordNode head;
- };
- #endif
Expand|Select|Wrap|Line Numbers
- #include <string>
- #include <fstream>
- #include <fstream>
- #include <iostream>
- #include <dinput.h>
- #include "BST.h"
- #include "WordNode.h"
- using namespace std;
- BST::BST()
- {
- //head;
- WordNode h("hey");
- };