#ifndef LIST_H_
#define LIST_H_
template
struct Node{
T num;
struct Node *next;
};
template
class List{
static const int MAX=10;
private:
//T t[MAX];
//int top;
Node
Node
int qsize;
Node
public:
//List
List();
~List();//构造函数有new ,必须显示析构
void add(const T &t);
bool isEmpty()const;
bool isFull()const;
//void set(const T &t)const;
void visit(){
Node
while((p++)!=nullptr)
{
cout<
}
};
};
#endif
List.cpp
#include
#include “List.h”
using namespace std;
template
List
{
front=rear=nullptr;
qsize=0;
}
template
List
{
delete front;//释放指向首指针的内容
}
template
void List
{
if(isEmpty())
{
Node
front=n;
n.num=t;
n.next=nullptr;
qsize++;
now=n;//令now指向当前节点
}
else if(isFull())
{
cout<<”List is full”<<endl;
}
else
{
Node
n.num=t;
now.next=n;
n.next=nullptr;
qsize++;
now=n;//令now指向当前节点
}
}
template
bool List
{
//front=nullptr;//不是不能改变里面的数据么?
qsize=100;
cout<<”const is not work! “<<qsize<<endl;
return front==nullptr;
}
template
bool List
{
return qsize==MAX;
}
main108.cpp
#include
#include “List.h”
using namespace std;
void main108()
{
//const int ar1[5]={1,2,3,4,5};
//double ar2[12]={1.1,2.2,3.3,4.4,5.5,6.6,7.7,8.8,9.9,10.1,11.2};
List
List
//for(int i=0;i<5;i++)
//arr1.add(ar1[i]);
arr1.add(10);
arr1.visit();
cin.get();
}
错误提示:
错误 3 error LNK2019: 无法解析的外部符号 “public: void __thiscall List
…..
—————————————————————————————————————————————————— //写的错误或者不好的地方请多多指导,可以在下面留言或者给我发邮件,指出我的错误以及不足,以便我修改,更好的分享给大家,谢谢。 转载请注明出处:https://www.royalchen.com/ author:royalchen Email:royalchen@royalchen.com ———————————————————————————————————————————————————
- 本文作者: royalchen
- 本文链接: http://www.royalchen.com/2016/02/24/cprimerplus第六版课后编程题答案108(来个高手教教我)/
- 版权声明: 本博客所有文章除特别声明外,均采用 MIT 许可协议。转载请注明出处!