Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(1) A templatized Stack Modify the code below to make the ADT Stack that is a template class has the code of the destructor in

(1) A templatized Stack

Modify the code below to make the ADT Stack that

  1. is a template class
  2. has the code of the destructor in which each node is directly deleted without using any member function. As each node is deleted, the destructor displays the address of the node that is being deleted.

(2) Testing

With a reference to main.cpp provided, enhance it so that you test Stack class for int type and Student type that are attached with this assignment. The required details are as follows.

  1. Each member function of the Stack class must be clearly tested for each data type, int and Student (16 tests = 8 member functions * 2 data types)
  2. From the output, the instructor must be able to clearly see what test is being done and how it is done.
  3. Do not interact with the user to receive inputs so that program testing time can be reduced.
  4. When you fill the stack with many keys or elements, use a loop for efficiency.
  5. Provide a makefile and remove unused functions and files.

HEADER FILE

#ifndef STUDENT_H #define STUDENT_H #include using namespace std;

class Student { private: float gpa; string ssn; public: void setGPA(float v); void setSSN(string s); void print();

class OutOfGPARange { }; // empty inner class definition under public class InvalidSSN { }; // empty inner class definition under public }; #endif

CPP FILE

#include #include "Student.h"

void Student::setGPA(float g) { //assert(g >= 0.0 && g <= 4.0);

//create an instance of the OutOfGPARange class, called exception if (g < 0.0 || g > 4.0) throw OutOfGPARange(); gpa = g; } void Student::setSSN(string s) { const int SSN_LENGTH = 9; if (s.length() != SSN_LENGTH) throw InvalidSSN(); //Checking each character is a digit should be here //Otherwise, throw InvalidSSN(); ssn = s; } void Student::print() { cout << "gpa: " << gpa << endl; cout << "ssn: " << ssn << endl; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Upgrading Oracle Databases Oracle Database New Features

Authors: Charles Kim, Gary Gordhamer, Sean Scott

1st Edition

B0BL12WFP6, 979-8359657501

More Books

Students also viewed these Databases questions

Question

=+(8.56) P"=A, + LA"A. H~2 and IA| Answered: 1 week ago

Answered: 1 week ago