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

Question 6 - C++ Classes Write a C++ class called license. Make sure it has the

ID: 3598262 • Letter: Q

Question

Question 6 - C++ Classes

Write a C++ class called license. Make sure it has the data items you specified for the C version you created in Question 1 and that the items are

initialized through parameters passed to the class constructor. You will need to write the class declaration and a class constructor. Also, please write at

least 5 "getter" functions to get access to specific private data items.

Note: Instead of char [ x ] for a character array that one uses in C, use the "string" type. See the C++ lecture notes for great examples as we created

many classes you can reuse.

See Code below

#include <stdio.h>
#define SIZE 5
struct date {
int month;
int day;
int year;
};
struct name {
char firstname[50];
char lastname[50];
char middlename[50];
};
struct height {
int feets;
int inches;
};
struct license {
char id[25]; // id
struct name n; // name struct which contains first name, last name, middle name
struct height h; // height struct which records both feets and inches
struct date dob; // date struct for date of birth
struct date expires; // date struct for expire date
struct date issued; // date struct for issued date
char sex; // char for sex 'M' or 'F'
char class_type; // license type. for example 'C'
char eyes_type[10]; // eye_color. for example "Blue"
};
int main() {
struct license drivers[SIZE]; // declaring license array
return 0;
}

Explanation / Answer

Here is the code :

class date {
public :
int month;
int day;
int year;
};

class name {
public :
string firstname;
string lastname;
string middlename;

};

class height {
public :
int feets;
int inches;
};

class license {

string id; // id
name n; // name struct which contains first name, last name, middle name
height h; // height struct which records both feets and inches
date dob; // date struct for date of birth
date expires; // date struct for expire date
date issued; // date struct for issued date
char sex; // char for sex 'M' or 'F'
char class_type; // license type. for example 'C'
string eyes_type; // eye_color. for example "Blue"

public :
license(string id ,name n, height h, date dob, date expires,date issued,char sex,char class_type,string eyes_type){

this -> id = id;
this -> n = n;
this -> h = h;
this -> dob = dob;
this -> expires = expires;
this -> issued = issued;
this -> sex = sex;
this -> class_type = class_type;
this -> eyes_type = eyes_type;
}

string getId(){
return this -> id;
}

name getName(){
return this -> n;
}

height getHeight(){
return this -> h;
}

date getDOB(){
return this -> dob;
}

date getExpireDate(){
return this -> expires;
}

date getIssuedDate(){
return this -> issued;
}

char getSex(){
return this -> sex;
}

char getClassType(){
return this -> class_type;
}

string getEyesType(){
return this -> eyes_type;
}
};

**If you have any query , please feel free to comment with details.

**Happy leaning :)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote