帮忙找下错误,不知道哪里错了

xiaowenmanbu 2008-03-27 03:41:34

#include <assert.h>
#include <iostream>
#include "stack.h"

using namespace std;

const int stackIncreament = 20;//栈溢出时扩展空间的增量

template<class T>
class SeqStack: public Stack<T> //顺序表的类定义
{
public:
SeqStack(int sz = 50); //建立一个空栈
~SeqStack() //析构函数
{
delete [] elements;
}
void Push(const T& x);
//如果IsFull(),则溢出处理,否则把x插入到栈的栈顶。
bool Pop(T& x);
//如果IsEmpty(),则不执行退栈,返回false;否则退掉栈顶的元素,返回true,
//退出的元素值通过引用型参数x返回。
bool getTop(T& x) const;
//如果IsEmpty(),返回false;否则返回true,通过引用型参数x得到栈顶元素的值。
bool IsEmpty() const
{
return (top == -1) ? true:false;
}
//如果栈中元素个数等于0,则返回true,否则返回false
bool IsFull() const
{
return (top == -1) ? true : false;
}
//如果栈中元素个数等于maxSize,则返回true,否则返回false。
int getSize() const //函数返回栈中元素个数
{
return top+1;
}
void MakeEmpty() //清空栈的内容
{
top = -1;
}
friend ostream& operator<<(ostream& os,SeqStack<T>& s);
//输出占中元素的重载操作<<
private:
T *elements;
int top;
int maxSize;
void overflowProcess();
void stackFull();
};


template<class T>
SeqStack<T>::SeqStack(int sz)//;top(-1),maxSize(sz)
{
//建立一个最大尺寸为sz的空栈,若分配不成功则错误处理
top = -1;
maxSize = sz;
elements = new T[maxSize];
assert(elements != NULL);
}

template<class T>
void SeqStack<T>::overflowProcess()
{
T * newArray = new T[maxSize + stackIncreament];
if(newArray = NULL)
{
cerr << "存储分配失败!" << endl;
exit(1);
}
for(int i = 0;i <= top; i++)
newArray[i] = elements[i];
maxSize = maxSize + stackIncreament;
delete [] elements;
elements = newArray;
}

template<class T>
void SeqStack<T>::Push(const T &x)
{
if(IsFull() == true)
stackFull();
// overflowProcess();
elements[++top] = x;
}

template<class T>
bool SeqStack<T>::Pop(T& x)
{
if(IsEmpty() == true)
return false;
x = elements[top--];
return true;
}

template<class T>
bool SeqStack<T>::getTop(T& x) const
{
if(IsEmpty() == true)
return false;
x = elements[top];
return true;
}

template<class T>
ostream& operator<<(ostream& os,SeqStack<T>& s)
{
os << "top = " << s.top << endl;
for( int i = 0; i <= s.top; i++)
os << i << ":" << s.elements[i] << endl;
return os;
}

template<class T>
void SeqStack<T>::stackFull()
{
T * newArray = new T[3 * maxSize];
if(newArray = NULL)
{
cerr << "存储分配失败!" << endl;
exit(1);
}
for(int i = 0;i <= top; i++)
newArray[i] = elements[i];
maxSize = 3 * maxSize;
delete [] elements;
elements = newArray;
}
...全文
159 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
txwcan999 2008-03-28
  • 打赏
  • 举报
回复
operator << 错误

看看作用域
Chappell 2008-03-27
  • 打赏
  • 举报
回复
#include "stack.h" -------> #include <stack>
public Stack <T> //顺序表的类定义 -------> public stack <T> //顺序表的类定义

xiaowenmanbu 2008-03-27
  • 打赏
  • 举报
回复
#include "stdafx.h"
#include "SeqStack.h"


int _tmain(int argc, _TCHAR* argv[])
{
SeqStack<int> s;
s.Push( 3 );
cout << s;
return 0;
}
csdn5211 2008-03-27
  • 打赏
  • 举报
回复
看看你的main那个文件是什么样,贴上来。
xiaowenmanbu 2008-03-27
  • 打赏
  • 举报
回复
>DS_3_9.obj : error LNK2019: 无法解析的外部符号 "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl operator<<(class std::basic_ostream<char,struct std::char_traits<char> > &,class SeqStack<int> &)" (??6@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@AAV01@AAV?$SeqStack@H@@@Z),该符号在函数 _wmain 中被引用
1>DS_3_9.obj : error LNK2001: 无法解析的外部符号 "public: virtual bool __thiscall Stack<int>::getTop(int &)const " (?getTop@?$Stack@H@@UBE_NAAH@Z)
1>G:\数据结构\DS_3_9\Debug\DS_3_9.exe : fatal error LNK1120: 2 个无法解析的外部命令
xiaowenmanbu 2008-03-27
  • 打赏
  • 举报
回复
>DS_3_9.obj : error LNK2019: 无法解析的外部符号 "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl operator<<(class std::basic_ostream<char,struct std::char_traits<char> > &,class SeqStack<int> &)" (??6@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@AAV01@AAV?$SeqStack@H@@@Z),该符号在函数 _wmain 中被引用
1>DS_3_9.obj : error LNK2001: 无法解析的外部符号 "public: virtual bool __thiscall Stack<int>::getTop(int &)const " (?getTop@?$Stack@H@@UBE_NAAH@Z)
1>G:\数据结构\DS_3_9\Debug\DS_3_9.exe : fatal error LNK1120: 2 个无法解析的外部命令
内容概要:SSD2828QN4是一款MIPI主桥接芯片,用于连接应用处理器与传统并行LCD接口及支持MIPI从属接口的LCD驱动器。该芯片支持最高每通道1Gbps的串行链路速度,最多可配置4个数据通道,显著减少了信号数量。它支持多种接口模式,包括RGB+SPI组合接口,适用于驱动智能或非智能显示面板,并能通过命令模式和视频模式传输数据。芯片内置时钟和复位模块、外部接口、协议控制单元(PCU)、包处理单元(PPU)、校正码/循环冗余校验(ECC/CRC)模块、长包和命令缓冲区、D-PHY控制器、模拟收发器以及内部锁相环(PLL),确保了高效的数据传输和系统稳定性。此外,文档详细描述了芯片的引脚分配、寄存器设置、操作模式、电源序列、时序特性等关键参数,为开发者提供了全面的技术指导。 适合人群:具备一定硬件设计基础,从事嵌入式系统开发、显示技术研究的研发人员。 使用场景及目标:①实现应用处理器与MIPI兼容显示屏之间的高速数据传输;②优化显示系统的功耗表现,减少电磁干扰(EMI);③通过灵活配置不同接口模式来适应各种显示设备的需求。 阅读建议:此文档面向具有一定电子工程背景的专业人士,建议读者结合实际项目需求深入理解各章节内容,特别是关于寄存器配置、时序要求等方面的具体说明。对于初次接触此类技术的开发者而言,建议先熟悉基本概念再逐步掌握高级功能的应用方法。

65,210

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧