我目前正在创建双在C继承与名单,其中有关于出版物的用户数据输入。该项目建立然而,当它进入出版物的第一个值(ISBN号)程序中断,给下面的错误:
未处理的异常在0x75045a0f在SDI2 Referal工作1.EXE:0XC0000005:存取违规读取位置0x00000014
它最初说,这个问题是在xstring但在搜索互联网后,我从项目属性发生改变。
这是我的联系list.h文件
#include <iostream>
#include <string>
using namespace std;
class publication
{
public:
string isbn;
string publisher;
};
class book: public publication
{
public:
string author;
string title;
};
class procedings: public publication
{
public:
string editor;
string date;
string title;
};
class node
{
friend class linkedList;
friend class book;
public:
node();
node();
void setNextNode(node *next);
node* getNextNode(void);
void setPrevNode(node *next);
node* getPrevNode(void);
void setData(int *data);
int* getData(void);
//private:
node *next;
node *prev;
int *data;
book *book;
procedings *procedings;
};
class linkedlist
{
friend class node;
public:
linkedlist();
void insertFromFront();
void insertFromEnd();
void deleteSpecifiedNode();
//private:
node *first;
node *last;
node *current;
};
node::node()
{
next = NULL;
prev = NULL;
data = NULL;
book = NULL;
procedings = NULL;
}
linkedlist::linkedlist()
{
first = NULL;
last = NULL;
current = NULL;
}
void linkedlist::insertFromFront()
{
node *temp;
temp = new node;
//cout << "Enter 1 for book or 2 for procedings: ";
//cin >> temp->data;
//if (temp->data == 1)
//{
cout << "Enter the book ISBN number: ";
cin >> temp->book->isbn;
cout << "Enter the book Publisher: ";
cin >> temp->book->publisher;
cout << "Enter the book Author: ";
cin >> temp->book->author;
cout << "Enter the book Title: ";
cin >> temp->book->title;
/*}
else if (temp->data == 2)
{
cout << "Enter the Procedings ISBN number: ";
cin >> temp->procedings->isbn;
cout << "Enter the Procedings Publisher: ";
cin >> temp->procedings->publisher;
cout << "Enter the Procedings Editor: ";
cin >> temp->procedings->editor;
cout << "Enter the Procedings Conference date: ";
cin >> temp->procedings->date;
cout << "Enter the Procedings Title: ";
cin >> temp->procedings->title;
}
else
{
cout << "Enter 1 for book or 2 for procedings: ";
cin >> temp->data;
}*/
temp->next = first;
first = temp;
}
//void linkedlist::insert_from_end()
// {
// node *temp, *temp1;
//
// temp = new node;
//
// cout << "Enter data: ";
// cin >> temp->data;
// temp->next = NULL;
//
// if(head == NULL)
// head = temp;
// else{
// temp1 = head;
// while(temp1->next != NULL)
// temp1 = temp1->next;
// temp1->next = temp;
// }
// }
//void linkedlist::delete_specified_node()
// {
// node *N2D; //node to delete
// node *temp; // keep track of the node before deleting
// int node_num;
//
// N2D = head;
//
// cout << "Enter node num:";
// cin >> node_num;
//
// temp->next = N2D->next;
// delete N2D;
// }
//
//
//