about phonebook appl. and person class

hi can you help with this code first this is person class :

#ifndef H_Person 20081106
#define H_Person 20081106

class Person {
public:
//constructer
Person();
//deconstructer
~Person();
const char *Firstname() const;
void Firstname (const char*);
const char *Lastname() const;
void Lastname (const char*);
const char *Phone() const;
void Phone (const char*);
const char Address() const;
void Address (const char*);
//copy constructer
Person (const Person &);
const Person & operator = (const Person &);

private:
char *firstname;
char*lastname;
char *address;
char *phone;


}

#endif /*H_Person 20081106*/


and this is person.cpp


include <cstdlib>
#include <iostream>
#include <string>
#include "Person.h"



Person::Person ():firstname_(new char[1]),
lastname_(new char[1]),
phone_(new char[1]),
address_(new char[1])
{

firstname_[0]=lastname_[0]=phone[0]=adress_[0]="\0";

}

Person::~Person (){

delete [] fisrtname_;
delete [] lastname_;
delete [] phone_;
delete [] address_;

}


char*dup (const char *s){
char *ret = new char [strlen(s)+1];
strcopy(ret,s);
return ret;

}

Person & Person::operator=(const Person &other){
if (this!=&other){
delete [] firstname_;
firstname_=dup(other fisrtname_);
delete [] lastname_;
lastname_=dup(other lastname_);
delete [] phone_;
phone_=dup(other phone_);
delete [] address_;
address_=dup(other address_);

}
return *this;
}


Person::Person (const Person &other):firstname_(0),
lastname_(0),
phone_(0),
address_(0) {

*this=other;

}




int main(int argc, char *argv[])
{


system("PAUSE");
return EXIT_SUCCESS;
}

i have to fill up main but i dunno how i am new for this stuff and i got error that "firstname_" is not declared
i guess one cunstructor is missing to but i dunno ; can you help with this
Last edited on
Topic archived. No new replies allowed.