Question: //contract.cpp #include Contact.h //Implementation file for the Contact class bool Contact:: operator > ( const Contact &right) { if (name > right.name) { return true

//contract.cpp #include "Contact.h" //Implementation file for the Contact class 

bool

Contact::

operator

> (

const

Contact &right) {

if

(name > right.name) {

return

true

; }

else

if

(name == right.name && email > right.name) {

return

true

; }

else

{

return

false

; } }

bool

Contact::

operator

< (

const

Contact &right) {

if

(name < right.name) {

return

true

; }

else

if

(name == right.name && email < right.email) {

return

true

; }

else

{

return

false

; } }

bool

Contact::

operator

== (

const

Contact &right) {

return

(name.compare(right.name) ==

0

&& email.compare(right.email) ==

0

); } ostream &

operator

<< (ostream &strm,

const

Contact &obj) { strm <<

"Name: "

<< obj.name <<

" Email: "

<< obj.email;

return

strm; } istream &

operator

>> (istream &strm, Contact &obj) {

cout

<<

"Name: "

; getline(strm,obj.name);

cout

<<

"Email: "

; getline(strm,obj.email);

return

strm; }

Contact.h

#ifndef CONTACT_H #define CONTACT_H //Specification file for the Contact class #include  #include  using namespace std; class Contact; //forward declaration //prototypes for overloaded stream operators ostream &operator << (ostream &, const Contact &); istream &operator >> (istream &, Contact &); //The Contact class holds a person's name and email class Contact { private: string name; string email; public: Contact() : Contact("","") { } Contact(string n, string em) { name = n; email = em; } void setName(string n) { name = n; } void setEmail(string em) { email = em; } string getName() const { return name; } string getEmail() const { return email; } bool operator > (const Contact &); bool operator < (const Contact &); bool operator == (const Contact &); friend ostream &operator << (ostream &, const Contact &); friend istream &operator >> (istream &, Contact &); }; #endif 

Main.cpp

#include  #include "Contact.h" //tests the Contact class for >> and << operations. using namespace std; int main() { Contact dummyobject; cin >> dummyobject; cout << dummyobject; return 0; } 

Using the textbook,class examples,or on line research, make a linked list template class that implements the basic linked list operations:

  • appending a node
  • traversing the list
  • inserting a node
  • deleting a node
  • destroying the list

Use a separate class template for the data type of the node. The constructor should store data in thevaluemember and set thenextpointer to nullptr.

The attached files contains an updated version of theContactclass seen previously in example programs. Several overloaded operators have been implemented, including <, >, ==, <<, and >>. The main program illustrates usage of the >> and << operators with an object of the class.

make a menu-driven program with the following options (program should loop until the exit option is selected):

  1. Add a contact
  2. Delete a contact
  3. Display all contacts
  4. Exit

All contacts should be sorted by name, then email. You are free to implement this in any manner you choose (although I would suggest "inserting a node"). Skip a line between contacts when displaying all contacts. When deleting a contact, the user should provide both a name and an email to remove (HINT: make a dummy object with those values and then traverse the list using the == operator to check for a match).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!