Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In C++.. //This is my header file for the class. Why does it say my identifiers,

ID: 3679494 • Letter: I

Question

In C++..

//This is my header file for the class. Why does it say my identifiers, firstName and lastName are undefined in the .cpp file?

#ifndef PERSONTYPE_H
#define PERSONTYPE_H
#include <string>
using namespace std;

class PersonType
{
public:
   PersonType();
   virtual void print();
   virtual void calculatePay();
   void setName(string, string);
   ~PersonType();
protected:
   string firstName, Lastname, gender;
   int age, tel, address, weight, height;
};

#endif

//This is my .cpp file for the class

#include "PersonType.h"

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

PersonType::PersonType()
{

}

void print() {

}

void calculatePay() {

}

void setName(string a, string b) {
   firstName = a;
   lastName = b;
}


PersonType::~PersonType()
{
}

Explanation / Answer

Try public access for the lastName, firstName in class PersonType.