My program is to print out the student inputted Name, Age,Mailing Address using classes, struct and h files.
I'm getting an undeclared identifier for my privates.
*****This is my Student.h file.******
#ifndef STUDENT_H
#define STUDENT_H
#include <iostream>
#include <string>
using namespace std;
struct Address
{
string street, city, state, zip;
};
class Student{
private:
string name;
Address MailingAddress;
Address PhysicalAddress;
double age;
public:
Student();
Student(string name, Address MailingAddress,Address PhysicalAddress, double age);
~Student();
void setName(string iname);
void setMailingAddress(Address iMailingAddress);
void setPhysicalAddress(Address iPhysicalAddress);
void setAge(double iage);
string getName();
Address getMailingAddress();
Address getPhysicalAddress();
double getAge();
};
#endif
****This is my one of my cpp****
#include "Student.h"
#include <string>
//INITIALIZATION
Student::Student(string n,Address mA,Address pA,double a)
{
name = n;
MailingAddress = mA;
PhysicalAddress = pA;
age = a;
}
Student::~Student()
{
cout << "Instance removed from memory" << endl;
}
//SETTERS
void Student::setName(string name)
{name = name;}
void Student::setMailingAddress(Address MailingAddress)
{MailingAddress = MailingAddress;}
void Student::setPhysicalAddress(Address PhysicalAddress)
{PhysicalAddress = PhysicalAddress;}
void Student::setAge(double age)
{age = age;}
//GETTERS
string Student::getName()
{return name;}
Address Student::getMailingAddress()
{return MailingAddress;}
Address Student::getPhysicalAddress()
{return PhysicalAddress;}
double Student::getAge()
{return age;}
Last edited on