0

我有以下代码:

void module_books::show_item(int n, TABLE<BOOK> b) {
  cout<<"Title:         "<<b[n]->title<<"\n";
  cout<<"Author:        "<<b[n]->author<<"\n";
  cout<<"Issue:         "<<"no. "<<b[n]->issueno<<". "<<b[n]->city<<", "<<b[n]->publisher<<", "<<b[n]->year<<"\n";
  cout<<"ISBN:          "<<b[n]->isbn<<"\n";
  cout<<"Pages count:   "<<b[n]->pages<<"\n";
  cout<<"Information:   Loan count: "<<b[n]->outcount<<". ";
  if(b[n]->damaged) cout<<"DAMAGED ";
  if(b[n]->out) cout<<"LOANED";
  cout<<"\n\n";
}

int module_books::add_item(TABLE<BOOK> &b) {

  int _year, _issueno, _pages;
  bool _damaged=false;
  string _title, _author, _isbn, _publisher, _city, stmp;

  cout<<"You're adding new book to the list.\nFill in the following fields:\n\n";
  cout<<"Title:               "; getline(cin,_title);
  cout<<"Author:              "; getline(cin,_author);
  cout<<"Issue no:            "; cin>>_issueno; cin.ignore(std::numeric_limits<std::streamsize>::max(), L'\n');
  cout<<"Issued in (city):    "; getline(cin,_city);
  cout<<"Issuer:              "; getline(cin,_publisher);
  cout<<"Issued in (year):    "; cin>>_year; cin.ignore(std::numeric_limits<std::streamsize>::max(), L'\n');
  cout<<"ISBN:                "; getline(cin,_isbn);
  cout<<"Pages count:         "; cin>>_pages;
  cout<<"Is damaged? (y/n):   "; cin>>stmp; cin.ignore(std::numeric_limits<std::streamsize>::max(), L'\n');
  if(stmp=="y" || stmp=="yes" || stmp=="Y" || stmp=="Yes" || stmp=="YES") _damaged=true;

  int n=b.size();

  b.push_back(BOOK(_title,_author,_publisher,_city,_isbn,_year,_issueno,_pages,_damaged));

  cout<<"\nThe book has been added:\n\n";
  show_item(n,b);
  cout<<"\nreturning\n";
  return n;
}

BOOK 只是一个带有一些成员变量的结构。TABLE 是一个结构模板,它的工作方式类似于 STL 向量(我只是不允许使用向量,所以必须编写我自己的模板,目前它使用的是静态数组T ar[100])。

问题是我收到了该书已添加的消息,并且 show_item 函数打印了所有数据,但我没有收到“返回”消息。

我尝试设置断点以使show_table函数到达结尾},但程序永远不会收到“返回”消息。

这段代码可能有什么问题?我将 32 位 QTCreator 与 MinGW 一起使用。如果有帮助的话,我的操作系统是 64 位 Win8.1...

4

0 回答 0