当前位置: 技术问答>linux和unix
问题!问题? 问题!?
来源: 互联网 发布时间:2014-11-30
本文导语: 以下程序是用tc3。0编译通过,选择的模式为紧凑模式。 最先开始分配返回的地址,段地址和偏移地址都不为0,但是分配了一些了以后返回的地址都为0,这是为什么呢?! ////////////////////////// //Header //CCharList.h class...
以下程序是用tc3。0编译通过,选择的模式为紧凑模式。
最先开始分配返回的地址,段地址和偏移地址都不为0,但是分配了一些了以后返回的地址都为0,这是为什么呢?!
//////////////////////////
//Header
//CCharList.h
class CCharListNode //In Heap....
{
public:
char cChar;
class CCharListNode far *pNext;
class CCharListNode far *pLast;
};
class CCharList
{
private:
CCharListNode far *pList;
CCharListNode far *pNodeOldLast;
unsigned int iNodeOldLast;
CCharListNode far* SeekNodeLast(unsigned int iPosition);
public:
unsigned int iListLength;
CCharList(void);
~CCharList(void);
int CreateList(void);
int InsertNode(char cChar, unsigned int iPosition);
int DeleteNode(unsigned int iPosition);
int DeleteList(void);
int GetCharFromNode(char &cChar, unsigned int iPosition);
int SetCharToNode(char cChar, unsigned int iPosition);
};
////////////////////
//cpp file
//CCharList.cpp
#include
#include
#include
#include
#include
#define Min(x, y) xpNext=pList;
pList->pLast=pList;
pNodeOldLast=pList;
iNodeOldLast=0;
return 1;
}
int CCharList::InsertNode(char cChar, unsigned int iPosition)
{
if(iPosition>iListLength+1 || iPositionSeekNodeLast(iPosition);
printf(" [%x:%x] ", FP_SEG(pNode), FP_OFF(pNode));
pNode->pNext=pSeek->pNext;
pSeek->pNext=pNode;
pNode->pLast=pSeek;
pNode->pNext->pLast=pNode;
pNode->cChar=cChar;
iListLength++;
return 1;
}
int CCharList::DeleteNode(unsigned int iPosition)
{
if(iPosition>iListLength || iPositionSeekNodeLast(iPosition);
pNode=pSeek->pNext;
pSeek->pNext=pNode->pNext;
pNode->pNext->pLast=pSeek;
farfree(pNode);
iListLength--;
return 1;
}
int CCharList::GetCharFromNode(char &cChar, unsigned int iPosition)
{
if(iPosition>iListLength || iPositionSeekNodeLast(iPosition);
cChar=pSeek->pNext->cChar;
return 1;
}
int CCharList::SetCharToNode(char cChar, unsigned int iPosition)
{
if(iPosition>iListLength || iPositionSeekNodeLast(iPosition);
pSeek->pNext->cChar=cChar;
return 1;
}
int CCharList::DeleteList(void)
{
int iLimit=iListLength;
for(unsigned int i=0; iDeleteNode(1);
farfree(pList);
return 1;
}
CCharList::~CCharList(void)
{
DeleteList();
}
CCharListNode far* CCharList::SeekNodeLast(unsigned int iPosition)
{
iPosition--;
CCharListNode far *pSeek;
unsigned int iDistanceFromHead;
unsigned int iDistanceFromOldLast;
unsigned int iDistanceTemp;
unsigned int iDistance;
iDistanceFromHead=Min(iListLength+1-iPosition, iPosition);
iDistanceTemp=iNodeOldLast
最先开始分配返回的地址,段地址和偏移地址都不为0,但是分配了一些了以后返回的地址都为0,这是为什么呢?!
//////////////////////////
//Header
//CCharList.h
class CCharListNode //In Heap....
{
public:
char cChar;
class CCharListNode far *pNext;
class CCharListNode far *pLast;
};
class CCharList
{
private:
CCharListNode far *pList;
CCharListNode far *pNodeOldLast;
unsigned int iNodeOldLast;
CCharListNode far* SeekNodeLast(unsigned int iPosition);
public:
unsigned int iListLength;
CCharList(void);
~CCharList(void);
int CreateList(void);
int InsertNode(char cChar, unsigned int iPosition);
int DeleteNode(unsigned int iPosition);
int DeleteList(void);
int GetCharFromNode(char &cChar, unsigned int iPosition);
int SetCharToNode(char cChar, unsigned int iPosition);
};
////////////////////
//cpp file
//CCharList.cpp
#include
#include
#include
#include
#include
#define Min(x, y) xpNext=pList;
pList->pLast=pList;
pNodeOldLast=pList;
iNodeOldLast=0;
return 1;
}
int CCharList::InsertNode(char cChar, unsigned int iPosition)
{
if(iPosition>iListLength+1 || iPositionSeekNodeLast(iPosition);
printf(" [%x:%x] ", FP_SEG(pNode), FP_OFF(pNode));
pNode->pNext=pSeek->pNext;
pSeek->pNext=pNode;
pNode->pLast=pSeek;
pNode->pNext->pLast=pNode;
pNode->cChar=cChar;
iListLength++;
return 1;
}
int CCharList::DeleteNode(unsigned int iPosition)
{
if(iPosition>iListLength || iPositionSeekNodeLast(iPosition);
pNode=pSeek->pNext;
pSeek->pNext=pNode->pNext;
pNode->pNext->pLast=pSeek;
farfree(pNode);
iListLength--;
return 1;
}
int CCharList::GetCharFromNode(char &cChar, unsigned int iPosition)
{
if(iPosition>iListLength || iPositionSeekNodeLast(iPosition);
cChar=pSeek->pNext->cChar;
return 1;
}
int CCharList::SetCharToNode(char cChar, unsigned int iPosition)
{
if(iPosition>iListLength || iPositionSeekNodeLast(iPosition);
pSeek->pNext->cChar=cChar;
return 1;
}
int CCharList::DeleteList(void)
{
int iLimit=iListLength;
for(unsigned int i=0; iDeleteNode(1);
farfree(pList);
return 1;
}
CCharList::~CCharList(void)
{
DeleteList();
}
CCharListNode far* CCharList::SeekNodeLast(unsigned int iPosition)
{
iPosition--;
CCharListNode far *pSeek;
unsigned int iDistanceFromHead;
unsigned int iDistanceFromOldLast;
unsigned int iDistanceTemp;
unsigned int iDistance;
iDistanceFromHead=Min(iListLength+1-iPosition, iPosition);
iDistanceTemp=iNodeOldLast
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
站内导航:
特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!