Hey all,
I am continuing with my self study and now I have come across classes. I have read about this
and read about this but it seems very alien to me.The problem I have selected to do is as follows:
Here is a rather simple class definition:
class Person
{
private:
static const LIMIT = 25;
string lname; // Person's last name
char fname[LIMIT]; //Person's first name
public:
Person() {lname=""; fname[0]='\0';} //#1
Person(const string & ln, const char * fn = "Hey you"); // #2
// the following methods display lname and fname
void Show() const; // firstname lastname format
void FormalShow() const; //lastname firstname format
};
Write a program that completes the implementation by providing code for the undefined
methods. The program in which you use the class should also use the three possible
constructor calls (no arguments, one argument and two arguments) and the two display
methods. Here's an example that uses the constructors and methods:
Person one; //use default constructor
Person two("Smythecraft"); //use #2 with one default argument
Person three("Dimwiddy", "Sam"); //use #2, no defaults
one.Show();
cout<< endl;
one.FormalShow(); //etc. for two and three
It seems as if there are 2 files left to write, since I have written the header file to be:
// person.h
#ifndef PERSON_H_
#define PERSON_H_
class Person
{
private:
static const LIMIT = 25;
string lname; // Person's last name
char fname[LIMIT]; //Person's first name
public:
Person() {lname=""; fname[0]='\0';} //#1
Person(const string & ln, const char * fn = "Hey you"); // #2
// the following methods display lname and fname
void Show() const; // firstname lastname format
void FormalShow() const; //lastname firstname format
};
#endif
The second file is where I don't seem to know what to do.
It seems as if I should define the functions from public.
Is there anyone out there that could sort of guide me in that direction?
I have tried reading other forums but the questions seem a bit more advanced.
All I need now is pointing in the right direction and later I can get more complicated.
I am using Dev-C++ with Windows XP.
Thanks as always!