Composition classes
this is the header file
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
#ifndef person_h
#define person_h
#include <iostream>
#include "address.h"
using namespace std;
class Person
{
public:
Person();
Person(const char *n, const char *g, const Address &ad);
Person(const person& f);
void setName(char *n);
void setType(char *g);
void setAds( Address ad );
char *getName();
char *getType();
Address getAds();
void printPersonDetails();
~Person();
private:
char *name;
char *gender;
Address ad;
};
#endif
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
#include "person.h"
#include <iostream>
using namespace std;
Person::Person()
{
strcpy(name, "UNKNOWN");
strcpy(gender,"UNKNOWN");
}
Person::Person(const char * n, const char * g, const Address & ad)
{
strcpy(name, n);
strcpy(gender,g);
}
Person::Person(const Person &f)
{
strcpy(name,f.name);
strcpy(gender, f.gender);
}
|
for the
Person::Person(const Person &f)
it shows an error...plzz help
For one - trying matching the case in your implementation to that in your class prototype. In the header file you have,
Person(const person& f);
Which should be,
Person(const Person& f);
Thnkkss =$
Topic archived. No new replies allowed.