Course Solutions Uncategorized (Solved) : Include Using Namespace Std Class Exception Exception Class Throwing Error Public Exceptio Q33026882 . . . .

(Solved) : Include Using Namespace Std Class Exception Exception Class Throwing Error Public Exceptio Q33026882 . . . .

 

#include <iostream>
using namespace std;

class Exception {//exception class for throwing error

public:
Exception(const string& msg) : msg_(msg) {}
~Exception() {}

string getMessage() const {return(msg_);}
private:
string msg_;
};

// We can use this for any data type that supports
template <typename T>
class OrderedList{//template class
public:
T *array;//create array of size 20
int size;
public:
OrderedList(int size){//constructor
//initialize array with size 20 of datatype T (i.e data type willbe alloted compile time)
array = new T[size];
this->size=size;//set size to class size variable
}
//The AddItem method should start at the front of the array whensearching
//for a place to insert a new item.
void AddItem(T data) {
try{
if(IsFull()){//if array is full throw error
throw(Exception(“Error :Array is full”));
}
  
} catch(Exception& e) {
cout << e.getMessage() << endl;
}
for(int i=0;i<size;i++){
if(IsEmpty(i)){
array[i]=data;

cout<<“Data

OR

PayPal Gateway not configured

OR

PayPal Gateway not configured

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post