我有一个问题,在TwoDimTree.h中Rectangle类不能正常工作 例如, “Rectangle Extent;”看起来像工作,但是当我尝试使用它说它没有找到成员类。使用未定义的类型C++,类
我想使用它像“Extent.get_Top;” ,但我无法做到。
也在我得到的错误列表。 错误7错误C2027:使用未定义类型'矩形'
我的标题是below.I真的找不到我的错误。感谢您的帮助。
我TwoDimTree.h
#include <string>
#include "Rectangle.h"
#include "LinkedList.h"
using namespace std;
class TwoDimTreeNode
{
public:
TwoDimTreeNode(Rectangle,TwoDimTreeNode*,TwoDimTreeNode*,TwoDimTreeNode*,TwoDimTreeNode*,LinkedList<Rectangle>,LinkedList<Rectangle>);
TwoDimTreeNode(Rectangle);
Rectangle get_Extent();
private:
Rectangle Extent;
LinkedList <Rectangle> Vertical;
LinkedList <Rectangle> Horizontal;
TwoDimTreeNode*TopLeft;
TwoDimTreeNode*TopRight;
TwoDimTreeNode*BottomLeft;
TwoDimTreeNode*BottomRight;
friend class Rectangle;
friend class LinkedList<Rectangle>;
};
我Rectangle.h
#include <string>
#include "TwoDimTreeNode.h"
#include "LinkedList.h"
using namespace std;
class Rectangle {
public:
Rectangle(int,int,int,int);
int get_Top();
void set_Top(int);
private:
int Top;
int Bottom;
int Right;
int Left;
friend class TwoDimTreeNode;
friend class LinkedList<Rectangle>;
};
我Linkedlist.h
#include <string>
#include "Rectangle.h"
#include "TwoDimTreeNode.h"
using namespace std;
template <class Object>
struct node
{
Object element;
node*next;
node(const Object & theElement = Object(),node*n=NULL)
:element(theElement), next(n){}
friend class Rectangle;
friend class TwoDimTreeNode;
};
template <class Object>
class LinkedList
{
public:
LinkedList();
int get_Length();
Object search(int,int);
bool check_Rectangle(Object);
private:
int length;
node<Object>*head;
};
你看看要创建一个通用的链表,但你硬编码它有'check_Rectangle'(为什么非矩形列表需要这个?)和朋友类的矩形包含属性。事实上,我会检查你需要这么多的朋友。你的'search'函数也返回所包含对象的一个副本。 –
我正在使用该程序只能找到矩形。 –