#ifndef AddressEditor_dot_h
#define AddressEditor_dot_h
#include "Editor.h"
#include "Address.h"
class AddressEditor:public Editor
{
public:
//empty object Address
AddressEditor();
//editing being object Address
AddressEditor(const Address& a);
//~AddressEditor();
bool edit();
Address addr()const {return addr_;}
void addr(const Address& a){addr_ = a;}
private:
//ban copy
AddressEditor(const AddressEditor&);
const AddressEditor& operator=(const AddressEditor&);
Address addr_;
}
#endif//AddressEditor_dot_h
Непонятные ошибки
Код:
и его реализация -
Код:
#include <iostream>
#include "AddressEditor.h"
AddressEditor::AddressEditor()//1error
{
}
AddressEditor::AddressEditor(const Address& a):addr_(a)
{
}
bool AddressEditor::edit()
{
std::string lastname(addr_.lastname());
std::string firstname(addr_.firstname());
std::string phone(addr_.phone());
std::string address(addr_.address());
editSingleLine("Last name",lastname)&&
editSingleLine("First name",firstname)&&
editSingleLinr("Phone Number",phone)&&
editSingleLine("Address",address);
if(status()==canceled)
return false;
//save change
addr_.lastname(lastname);
addr_.firstname(firstname);
addr_.phone(phone);
addr_.address(address);
return true;
}
#include "AddressEditor.h"
AddressEditor::AddressEditor()//1error
{
}
AddressEditor::AddressEditor(const Address& a):addr_(a)
{
}
bool AddressEditor::edit()
{
std::string lastname(addr_.lastname());
std::string firstname(addr_.firstname());
std::string phone(addr_.phone());
std::string address(addr_.address());
editSingleLine("Last name",lastname)&&
editSingleLine("First name",firstname)&&
editSingleLinr("Phone Number",phone)&&
editSingleLine("Address",address);
if(status()==canceled)
return false;
//save change
addr_.lastname(lastname);
addr_.firstname(firstname);
addr_.phone(phone);
addr_.address(address);
return true;
}
тестовая программа:
Код:
#include <iostream>
#include "Address.h"
#include "AddressEditor.h"
void dump(const Address& a)//2 error
{
std::cout<<"Record "<<a.recordId()<<'\n'
<<a.firstname()<<' '<<a.lastname()<<'\n'
<<a.address()<<'\n'<<a.phone()<<'\n'<<std::endl;
}
int main()
{
Address a;
AddressEditor editor(a);
while(a.lastname() != "done")
{
editor.edit();
a = editor.addr();
std::cout<<std::endl;
dump(a);
}
return 0;
}
#include "Address.h"
#include "AddressEditor.h"
void dump(const Address& a)//2 error
{
std::cout<<"Record "<<a.recordId()<<'\n'
<<a.firstname()<<' '<<a.lastname()<<'\n'
<<a.address()<<'\n'<<a.phone()<<'\n'<<std::endl;
}
int main()
{
Address a;
AddressEditor editor(a);
while(a.lastname() != "done")
{
editor.edit();
a = editor.addr();
std::cout<<std::endl;
dump(a);
}
return 0;
}
Ошибки пишет следующие:
1. c:\documents and settings\administrator\мои документы\visual studio projects\tinypim\addresseditor.cpp(6): error C2533: 'AddressEditor::__ctor' : constructors not allowed a return type
2.c:\documents and settings\administrator\мои документы\visual studio projects\tinypim\addredittest.cpp(5): error C2628: 'AddressEditor' followed by 'void' is illegal (did you forget a ';'?)
Sorry,ЗАРАНИЕ БЛАГОДАРЕН!
все,вопрос решен,спасибо всем кто посмотрел