节点标题:
#pragma once
class TestClass
{
public:
int x, y;
TestClass *next;
TestClass *prev;
TestClass();
TestClass(int,int);
~TestClass();
};
节点基类
#include "stdafx.h"
#include "TestClass.h"
TestClass::TestClass()
{
}
TestClass::TestClass(int _x, int _y)
{
x = _x;
y = _y;
}
TestClass::~TestClass()
{
}
标题列表类
#pragma once
class List
{
public:
TestClass *first;
TestClass *last;
List();
~List();
void AddNew(TestClass);
void PrintList();
};
列出基类
#include "stdafx.h"
#include "List.h"
#include "TestClass.h"
#include <iostream>
using namespace std;
List::List()
{
first = last = NULL;
}
List::~List()
{
}
void List::AddNew(TestClass node)
{
if (!first && !last)
{
*first = *last = node;
//first = last = &node;
}
else
{
TestClass *temp;
temp = last;
last = &node;
temp->next = last;
}
}
void List::PrintList()
{
TestClass *p = first;
while (p != NULL)
{
cout << p->x << " ";
p = p->next;
}
}
我遇到了16个错误,例如:
你能伸出援助之手吗?
答案 0 :(得分:1)
#include "TestClass.h
中的 List.h
。
答案 1 :(得分:1)
标题列表类应包含标题节点标题,因为它引用了它的声明。