Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please make sure you have to write table.t File and you will have to create tableSpecificOps 1 . cpp and table.cpp as well. Question:Design a

Please make sure you have to write table.t File and you will have to create tableSpecificOps1.cpp and table.cpp as well. Question:Design a table ADT Specifically write a table class.It must be generic ( i.e. templated ) and contain all the necessary attributes and actions ( data members and member functions ) for the table class to behave as expected. You must write a table.t file that works for the provided files: tableSpecificOps1.h, table.h pair.h pair.cpp driver.cpp.
( you will have to create tableSpecificOps1.cpp and table.cpp as well ). This is tableSpecificOps.h #include "table.h"
#ifndef TABLE_SPCIFIC1_H
#define TABLE_SPCIFIC1_H
int f( char c);
int f1( double d);
#endif This is "pair.h" #ifndef PAIR_H
#define PAIR_H
// more or less from STL library
// found in and
template class T1, class T2>
class Pair
{
public:
T1 first;
T2 second;
// default constructor
Pair(): first( T1()), second( T2())
{}
// constructor that initializes first and second
Pair( const T1 v1, const T2 v2):
first(v1), second(v2)
{}
//copy constructor
template typename U1, typename U2>
Pair ( const Pair& X)
: first( X.first ), second( X.second )
{}
// overload =
template typename U1, typename U2>
Pair& operator=( const Pair& init )
{
return *this = Pair(init);
}
// overload
friend bool operator( const Pair& lhs, const Pair& rhs )
{return lhs.first rhs.first ||!( rhs.first lhs.first && lhs.second rhs.second );
}
// overload ==
friend bool operator==( const Pair& lhs, const Pair& rhs )
{
return lhs.first == rhs.first && lhs.second == rhs.second ;
}
};
template class T1, class T2>
Pair makePair( const T1& v1, const T2& v2)
{
return Pair T1, T2>(v1,v2);
}
#endif This is "Driver.cpp"/* sample driver which your lab should demo */
#include
using std::cout;using std::cin;using std::endl;
#include "pair.h"#include "table.h"
/* where the mapping function is defined */
#include "tableSpecificOps1.h"
int main()
{
Table char, int > t(7, f);
Pair char, int > p1('a',222); Pair char, int > p2('d',666); Pair char, int > p3('e',111);
t.insert( p1); t.insert( p2);
t.print();cout endl;
char someKey ='d'; t.remove(someKey);
t.print();cout endl;
t.insert( p3);t.print(); cout endl;
cout t.lookUp('e');cout endl;
cout t.lookUp('z'); cout endl;
t.insert(( makePair('b',123)));
t.print(); cout endl;
return (0);} Finaly, "table.h" screenshot below Thank you so much
image text in transcribed

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_2

Step: 3

blur-text-image_3

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

Advances In Spatial And Temporal Databases 10th International Symposium Sstd 2007 Boston Ma Usa July 2007 Proceedings Lncs 4605

Authors: Dimitris Papadias ,Donghui Zhang ,George Kollios

2007th Edition

3540735399, 978-3540735397

More Books

Students also viewed these Databases questions