Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please make sure you have to create table.t and also you will have to create tableSpecificOps 1 . cpp and table.cpp . Please I need

Please make sure you have to create table.t and also you will have to create tableSpecificOps1.cpp and table.cpp.Please I need full code so I can see its work successfully and output too. Because when put code on our program came with a lot off error. Thank YOU 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 "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 another file "tableSpecificOps1.h" #include "table.h"
#ifndef TABLE_SPCIFIC1_H
#define TABLE_SPCIFIC1_H
int f( char c);
int f1( double d);
#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);
} Finally "Table.h" screeshot Bellow
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

Modern Database Management

Authors: Heikki Topi, Jeffrey A Hoffer, Ramesh Venkataraman

13th Edition

0134773659, 978-0134773650

More Books

Students also viewed these Databases questions

Question

How do Dimensional Database Models differ from Relational Models?

Answered: 1 week ago

Question

What type of processing do Relational Databases support?

Answered: 1 week ago

Question

Describe several aggregation operators.

Answered: 1 week ago