我用过的编译器都不能调试它。我正在尝试在列表末尾添加一个新节点,然后显示它,它们没有显示任何类型的错误,两者都给出了发送不发送窗口的错误,我认为这可能是内存泄漏..请帮我
#include <iostream>
#include <conio.h>
using namespace std;
struct Node
{
int data;
Node *nextptr;
};
class CLLIST{
private:
Node*firstptr;
Node*lastptr;
public:
CLLIST(){
cout << "Constructor Called !";
firstptr=lastptr=NULL;
}
void insert_at_back(int val){
cout << " \n \n I am in the insert at back function: ";
Node*newptr;
newptr = new Node;
newptr->data=val;
if(firstptr=NULL)//means list is empty
{
firstptr=newptr;
}else{
lastptr->nextptr=newptr;
}
lastptr=newptr;
lastptr->nextptr=firstptr;
}
void display(){
Node *temptr,*endptr;
temptr = new Node;
endptr = new Node;
temptr=firstptr;
endptr = NULL;
while(temptr!=endptr){
cout << "I am in the display Function: ";
cout << firstptr->data << " ";
firstptr=firstptr->nextptr;
endptr=firstptr;}
delete temptr;
delete endptr;
}
};
int main()
{
CLLIST obj1;
obj1.insert_at_back(26);
obj1.display();
cout << " \n \n Done !";
getch();
}