#ifndef AddressBookMenu_dot_h
#define AddressBookMenu_dot_h 1
#include "Menu.h"
#include "AddressDisplayList.h"
class AddressBookMenu:public Menu
{
public:
AddressBookMenu(AddressBook& addrBook)
:addressBook_(addrBook),displayList_(addrBook){}
void mainLoop();
private:
void viewEntry();
void createEntry();
void editEntry();
void deleteEntry();
void listAll();
void lookup();
void search();
AddressBook& addressBook_;
AddressDisplayList displayList_;
};
#endif //AddressBookMenu_dot_h
Ошибочка
Цитата:
c:\documents and settings\administrator\мои документы\visual studio projects\tinypim\addressbookmenu.cpp(166) : warning C4551: function call missing argument list
Linking...
TinyPIM.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall Menu::~Menu(void)" (??1Menu@@UAE@XZ) referenced in function __unwindfunclet$??0AddressBookMenu@@QAE@AAVAddressBook@@@Z$0
TinyPIM.obj : error LNK2019: unresolved external symbol "public: __thiscall Menu::Menu(void)" (??0Menu@@QAE@XZ) referenced in function "public: __thiscall AddressBookMenu::AddressBookMenu(class AddressBook &)" (??0AddressBookMenu@@QAE@AAVAddressBook@@@Z)
Debug/TinyPIM.exe : fatal error LNK1120: 2 unresolved externals
Linking...
TinyPIM.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall Menu::~Menu(void)" (??1Menu@@UAE@XZ) referenced in function __unwindfunclet$??0AddressBookMenu@@QAE@AAVAddressBook@@@Z$0
TinyPIM.obj : error LNK2019: unresolved external symbol "public: __thiscall Menu::Menu(void)" (??0Menu@@QAE@XZ) referenced in function "public: __thiscall AddressBookMenu::AddressBookMenu(class AddressBook &)" (??0AddressBookMenu@@QAE@AAVAddressBook@@@Z)
Debug/TinyPIM.exe : fatal error LNK1120: 2 unresolved externals
определение класса:
Код:
реализация такая:
Код:
#ifdef _NSC_VER
#pragma warning (disable:4786)
#endif
#include <iostream>
#include <iomanip>
#include <climits>
#include "AddressBookMenu.h"
#include "Address.h"
#include "AddressBook.h"
#include "AddressEditor.h"
void AddressBookMenu::mainLoop()
{
clearScreen();
std::cout<<"*** Address Book ***\n\n";
displayList_.display();
std::cout<<'\n';
static const char menu[] =
"(P)revious,(N)ext,(V)iew,(C)reate,(D)elete,(E)dit,\n"
"list (A)ll,(L)ookup,(S)earch,(R)edisplay,(Q)uit?";
static const char choices[] = "PNVCDEALSRQ";
switch(getMenuSelection(menu,choices))
{
case 'P':
displayList_.pageUp();
break;
case 'N':
displayList_.pageDown();
break;
case 'V':
viewEntry();
break;
case 'C':
createEntry();
break;
case 'D':
deleteEntry();
break;
case 'E':
editEntry();
break;
case 'A':
listAll();
break;
case 'L':
lookup();
break;
case 'S':
search();
break;
case 'R':
break;
case 'Q':
exitMenu();
break;
default:
exitMenu();
break;
}
}
void AddressBookMenu::viewEntry()
{
int recordId = displayList_.selectRecord();
if (recordId==0)
return;
Address addr = addressBook_.getAddress(recordId);
std::cout<<"\nName:"<<addr.lastname();
if(!addr.firstname().empty())
std::cout<<", "<<addr.firstname();
std::cout<<"\nPhone: "<<addr.phone();
std::cout<<"\nAddress: "<<addr.address();
std::cout<<"\n\nPress [RETURN] when ready.";
std::cin.ignore(INT_MAX,'\n');
}
void AddressBookMenu::createEntry()
{
//Edit clear object Address
AddressEditor editor;
Address addr;
//Continue edit to save object or canceled edit
while(editor.edit())
{
addr = editor.addr();
if(addr.lastname().empty())
{
std::cout<<"Last name must not be empty."
<<std::endl;
continue;//continue of cycle for entry new edit
}
int duplicates = addressBook_.countName(addr.lastname(),
addr.firstname());
int recordId=0;
if(duplicates == 0)
{
//duplicate not found,it is possible create new entry
recordId=addressBook_.insertAddress(addr);
//scrolling list for imagery new added entry
displayList_.scrollToTop(recordId);
return;
}
else
{
std::cout<<"There are already "<<duplicates
<<" records with this name.\n";
switch (getMenuSelection(
"(S)ave a new record,(E)dit record or(C)ancel?","SEC"))
{
case 'S'://save entry
recordId = addressBook_.insertAddress(addr);
displayList_.scrollToTop(recordId);
return;
case 'E':
continue;
case 'C':
default:
return;
}
}
}
}
void AddressBookMenu::deleteEntry()
{
int recordId = displayList_.selectRecord();
if (recordId==0)
return;
int firstVisible = displayList_.screenRecord(0);
if (firstVisible == recordId)
firstVisible = displayList_.screenRecord(1);
addressBook_.eraseAddress(recordId);
displayList_.reset();
if(firstVisible !=0)
displayList_.scrollToTop(firstVisible);
}
void AddressBookMenu::editEntry()
{
int recordId = displayList_.selectRecord();
if (recordId==0)
return;
Address addr = addressBook_.getAddress(recordId);
AddressEditor editor(addr);
if(editor.edit())
{
addressBook_.replaceAddress(editor.addr());
displayList_.reset;
displayList_.scrollToTop(recordId);
}
}
void AddressBookMenu::lookup()
{
std::string lkupname;
std::cout<<"lookup name(lastname[, firstname]):";
std::getline(std::cin,lkupname);
if(lkupname.empty())
return;
std::string::size_type lastNameEnd = lkupname.find(",");
std::string::size_type firstNameStart = std::string::npos;
if(lastNameEnd != std::string::npos)
firstNameStart = lkupname.find_first_not_of(", \t\f\n\v",
lastNameEnd);
if(firstNameStart == std::string::npos)
displayList_.findNameStartsWith(lkupname.substr(0,lastNameEnd));
else
displayList_.findNameStartsWith(lkupname.substr(0,lastNameEnd),
lkupname.substr(firstNameStart));
}
void AddressBookMenu::search()
{
std::string searchString;
std::cout<<"Search for string:";
std::getline(std::cin,searchString);
if(searchString.empty())
return;
displayList_.listContainsString(searchString);
}
void AddressBookMenu::listAll()
{
displayList_.listAll();
}
#pragma warning (disable:4786)
#endif
#include <iostream>
#include <iomanip>
#include <climits>
#include "AddressBookMenu.h"
#include "Address.h"
#include "AddressBook.h"
#include "AddressEditor.h"
void AddressBookMenu::mainLoop()
{
clearScreen();
std::cout<<"*** Address Book ***\n\n";
displayList_.display();
std::cout<<'\n';
static const char menu[] =
"(P)revious,(N)ext,(V)iew,(C)reate,(D)elete,(E)dit,\n"
"list (A)ll,(L)ookup,(S)earch,(R)edisplay,(Q)uit?";
static const char choices[] = "PNVCDEALSRQ";
switch(getMenuSelection(menu,choices))
{
case 'P':
displayList_.pageUp();
break;
case 'N':
displayList_.pageDown();
break;
case 'V':
viewEntry();
break;
case 'C':
createEntry();
break;
case 'D':
deleteEntry();
break;
case 'E':
editEntry();
break;
case 'A':
listAll();
break;
case 'L':
lookup();
break;
case 'S':
search();
break;
case 'R':
break;
case 'Q':
exitMenu();
break;
default:
exitMenu();
break;
}
}
void AddressBookMenu::viewEntry()
{
int recordId = displayList_.selectRecord();
if (recordId==0)
return;
Address addr = addressBook_.getAddress(recordId);
std::cout<<"\nName:"<<addr.lastname();
if(!addr.firstname().empty())
std::cout<<", "<<addr.firstname();
std::cout<<"\nPhone: "<<addr.phone();
std::cout<<"\nAddress: "<<addr.address();
std::cout<<"\n\nPress [RETURN] when ready.";
std::cin.ignore(INT_MAX,'\n');
}
void AddressBookMenu::createEntry()
{
//Edit clear object Address
AddressEditor editor;
Address addr;
//Continue edit to save object or canceled edit
while(editor.edit())
{
addr = editor.addr();
if(addr.lastname().empty())
{
std::cout<<"Last name must not be empty."
<<std::endl;
continue;//continue of cycle for entry new edit
}
int duplicates = addressBook_.countName(addr.lastname(),
addr.firstname());
int recordId=0;
if(duplicates == 0)
{
//duplicate not found,it is possible create new entry
recordId=addressBook_.insertAddress(addr);
//scrolling list for imagery new added entry
displayList_.scrollToTop(recordId);
return;
}
else
{
std::cout<<"There are already "<<duplicates
<<" records with this name.\n";
switch (getMenuSelection(
"(S)ave a new record,(E)dit record or(C)ancel?","SEC"))
{
case 'S'://save entry
recordId = addressBook_.insertAddress(addr);
displayList_.scrollToTop(recordId);
return;
case 'E':
continue;
case 'C':
default:
return;
}
}
}
}
void AddressBookMenu::deleteEntry()
{
int recordId = displayList_.selectRecord();
if (recordId==0)
return;
int firstVisible = displayList_.screenRecord(0);
if (firstVisible == recordId)
firstVisible = displayList_.screenRecord(1);
addressBook_.eraseAddress(recordId);
displayList_.reset();
if(firstVisible !=0)
displayList_.scrollToTop(firstVisible);
}
void AddressBookMenu::editEntry()
{
int recordId = displayList_.selectRecord();
if (recordId==0)
return;
Address addr = addressBook_.getAddress(recordId);
AddressEditor editor(addr);
if(editor.edit())
{
addressBook_.replaceAddress(editor.addr());
displayList_.reset;
displayList_.scrollToTop(recordId);
}
}
void AddressBookMenu::lookup()
{
std::string lkupname;
std::cout<<"lookup name(lastname[, firstname]):";
std::getline(std::cin,lkupname);
if(lkupname.empty())
return;
std::string::size_type lastNameEnd = lkupname.find(",");
std::string::size_type firstNameStart = std::string::npos;
if(lastNameEnd != std::string::npos)
firstNameStart = lkupname.find_first_not_of(", \t\f\n\v",
lastNameEnd);
if(firstNameStart == std::string::npos)
displayList_.findNameStartsWith(lkupname.substr(0,lastNameEnd));
else
displayList_.findNameStartsWith(lkupname.substr(0,lastNameEnd),
lkupname.substr(firstNameStart));
}
void AddressBookMenu::search()
{
std::string searchString;
std::cout<<"Search for string:";
std::getline(std::cin,searchString);
if(searchString.empty())
return;
displayList_.listContainsString(searchString);
}
void AddressBookMenu::listAll()
{
displayList_.listAll();
}
Зарание всем благодпрен,с уважением...
public: virtual __thiscall Menu::~Menu(void)
Дык это ведь виртуальный деструктор,что должно напугать?
ПРОБЛЕММУ РЕШИЛ
public: virtual __thiscall Menu::~Menu(void)[/QUOTE]
Это должно не пугать, а радовать. В большинстве случаев виртуальный деструктор - это хороший тон.