family.h header file #pragma once #ifndef family_h #define family_h #endif struc
ID: 3862602 • Letter: F
Question
family.h header file
#pragma once
#ifndef family_h
#define family_h
#endif
struct person
{
char FN[30];
char LN[30];
int age;
};
class Family
{
private:
char name[30];
person parent[2];
person children[10];
public:
void setName(char* n[30]);
char * getName();
void setParent(char FN[], char LN[], int, int);
void setChildren(char FN[], char LN[], int, int);
};
****** family.cpp implement file*****
#include "Family.h"
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
void Family::setName(char* n[])
{
strcpy(name, *n);
};
char* Family::getName()
{
return name;
};
void Family::setParent(char FN[], char LN[], int age, int index)
{
strcpy(parent[index].FN, FN);
strcpy(parent[index].LN, FN);
parent[index].age = age;
};
void Family::setChildren(char FN[], char LN[], int age, int index)
{
strcpy(children[index].FN, FN);
strcpy(children[index].LN, FN);
children[index].age = age;
};
I need help with writting the following programs
-Create the program lab_main.cpp which uses the class Family to Implement the following a.
The program will allow the user to
1. Add families
a. With one or two parents
b. With zero or more children
2. Delete Families search by last name (should use the same search function from item 3 below.
3. Display Families searching by last name
4. Display a list of all families 4.
On exit print the following text to the screen; “So long from the family!” where is the first family in the list (if the list is empty just print “Bye Bye”).
*** PLEASE DO NOT SIMPLY ANSWER ***
*** I NEED A REAL SOLUTION ***
Explanation / Answer
#pragma once
#ifndef family_h
#define family_h
#endif
struct person
{
char FN[30];
char LN[30];
int age;
};
class Family
{
private:
char name[30];
person parent[2];
person children[10];
public:
void setName(char* n[30]);
char * getName();
void setParent(char FN[], char LN[], int, int);
void setChildren(char FN[], char LN[], int, int);
};
****** family.cpp implement file*****
#include "Family.h"
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
void Family::setName(char* n[])
{
strcpy(name, *n);
};
char* Family::getName()
{
return name;
};
void Family::setParent(char FN[], char LN[], int age, int index)
{
strcpy(parent[index].FN, FN);
strcpy(parent[index].LN, FN);
parent[index].age = age;
};
void Family::setChildren(char FN[], char LN[], int age, int index)
{
strcpy(children[index].FN, FN);
strcpy(children[index].LN, FN);
children[index].age = age;
};
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.