Help with PersonType.h : No such file or directory error.

I need some assistance trying to figure out why my program is not compiling properly. When I try to compile the program I am getting PersonType.h : No such file or directory error.

Here is description of my assignment :

1. Create a person class to represent a person. (You may call the class personType.) To simplify things, have the class have 2 variable members for the person's first and last name. Include 2 constructors. One should be a default constructor and the other should be one with parameters. Include respective functions for:
o setting the name,
o getting the name, and
o printing the name on the screen.

Have your main program call these functions to demonstrate how they work.
Explain how you can replace both constructors with one constructor by using a single constructor with default parameters.


Code :

#include <personType.h>

personType::personType()
{
//default constructor
firstName = "No";
lastName = "Name";
}

personType::personType(string f, string l)
{
//another constructor, with parameters
setName(f, l);
}

void personType::setName(string f, string l) {
// set the full name (first and last)
firstName = f;
lastName = l;
}

void personType::setFName(string name) {
// set the first name
firstName = name;
}

void personType::setLName(string name) {
// set the last name
lastName = name;
}

// 3 methods to get first, last and full name
string personType::getFName() {
return firstName;
}

string personType::getLName() {
return lastName;
}

string personType::getName() {
return firstName + " " + lastName;
}

// print name
void personType::printName() {
cout << firstName.c_str() << " " << lastName.c_str() << endl;
}

MAIN
/*Explain how you can replace both constructors with one
constructor by using a single constructor with default parameters.

I can have default parameters, such as
personType(string f = "No", string l="Name");

*/

#include "personType.h"
using namespace std;

int main()
{
string f, l;
cout << "Enter first name: ";
cin >> f;
cout << "Enter last name: ";
cin >> l;

personType *p = new personType(f, l);
personType def;

cout << "Default person is ";
def.printName();
cout << "Your name is ";
p->printName();

cout << "Enter new first name: ";
cin >> f;
cout << "Enter new last name: ";
cin >> l;
p->setName(f, l);
cout << "Your new name is ";
p->printName();
return 0;
}
HEADER
#ifndef PERSONTYPE_H
#define PERSONTYPE_H

#include "string"
#include <iostream>
using namespace std;

class personType
{
public:
personType();
personType(string f, string l);
void setName(string f, string l);
void setFName(string name);
void setLName(string name);
string getFName();
string getLName();
string getName();
void printName();
private:
string firstName;
string lastName;
};

Can someone please help me correct this program? Thank you
Your compiler is missing a file named "PersonType.h". Depending on your platform case may be significant. So "personType.h" may be different than "PersonType.h".
Hello TCS

I am using Dev C++ to compile this code. Do you recommend another compiler I could use. I am new to C++ . I checked the help guide on DevC++ and I don't see any help for personType.h
There's surely no help for personType.h in your C++ manual ;-) I think yo've to write it yourself:
Create a person class to represent a person.
By convention a class specification should be written into a file named by the class name followed by the suffix ".h". The last lines of your example code starting with class personType should be written into a file called "personType.h".

Or did I missunderstand your problem?
Topic archived. No new replies allowed.