QuestionQuestion

In this assignment, you will create a class, Person, and learn/review considerations specific to a class that makes use of dynamic memory allocation and de-allocation for at least one member data object. You will also thoroughly test your class to verify that everything you want it to do is done correctly and efficiently.

class Person
{
    //Private member data for:
    //    1. m_name: name of the person (char *).
    //    2. m_age: age of the person (int).
    //    3. m_ssn: social security number of the person
    //             (string for now: ddd-dd-dddd).
    //Public functions:
    //    1. Person(), Person(const char * name, int age, const string &ssn),
    //       Person(const Person &p)
    //    2. Destructor.
    //    3. Overloaded assignment operator.
    //    4. As discussed in class, provide "accessor" and "mutator" functions for
    //       each of the member data items in the class.
    //    5. Overloaded input and output operators.
};

Tested thoroughly means:

All constructors tested.
All accessor and mutator functions tested.
All overloaded operators tested.
Specific to input and output operators:
a.Tested for both “common” I/O and file I/O.
b.For file I/O, write out at least two objects to a file, read the objects back into different variables. Verify that the corresponding objects are indeed the same.
Test a “const” object to make sure all operations possible on a “const” object function as required.

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

#include <cstdlib>
#include <iostream>
#include <fstream>
#include "Person.h"

using namespace std;

int main(int argc, char** argv) {
   
cout << "All constructors tested\n";
cout << "Default construtor:\n";
    Person p1;
    cout << p1 << "\n";
cout << "Constructor with paramenters:\n";
Person p2("Cho", 20, "2-15-1995");
cout << p2 << "\n";

cout << "Copy constructor:\n";
Person p3(p2);
cout << p3 << "\n";


cout << "All accessor and mutator functions tested:\n";
cout << p1 << "\n";
cout << "mutator: \n";
cout << "Age: " << p1.getAge() << "\n";
cout << "Name: " << p1.getName() << "\n";
cout << "SSN: " << p1.getSSN() << "\n";
cout << "\n";

cout << "All overloaded operators tested:\n";
cout << "Assigment operator:\n";
cout << "before:\n";
cout << p1 << "\n";
p1 = p2;
cout << "after:\n";...

By purchasing this solution you'll be able to access the following files:
Solution.zip.

$15.00
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Visual Basic Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats