Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I Need help with my lab my output coming wrong could you fix it for me ? ? ? I posted my question below and
I Need help with my lab my output coming wrong could you fix it for me I posted my question below and also added my code too please fix it & show the output that work successfully Thank You Design a table ADT Specifically write a table class. It must be generic ie 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: tableSpecificOpsh table.h pair.h pair.cpp driver.cpp
you will have to create tableSpecificOpscpp and table.cpp as well Im provided my file : "tableSpecificOpsh #pragma once #ifndef TABLESPCIFICH
#define TABLESPCIFICH
int fchar c;
int fdouble d;
#endif This is "tableSpecificOpscpp #include "tableSpecificOpsh
int fchar c
Function body return c;
int fdouble d
Function body return d; This is "table.h #pragma once
#ifndef TABLEH
#define TABLEH
#include
#include "pair.h
template
class Table
public:
typedef T keytype;
private:
int tableSize;
Pair thetable;
int MappingKey k;
public:
void print;
Tableint n int mapKey k;
bool insertPair kvpair;
bool removeconst Key aKey;
T lookUpconst Key aKey;
Tableconst Table& initTable;
~Table;
Table& operatorconst Table& initTable;
;
#include "table.t
#endif This is "table.t #ifndef TABLET
#define TABLET
#include "table.h
template
void Table::print
for int i ; i tableSize; i
std::cout thetableifirst : thetableisecond std::endl;
template
Table::Tableint n int mapKey k : tableSizen Mappingmap
thetable new PairtableSize;
template
bool Table::insertPair kvpair
int index Mappingkvpairfirst;
if index && index tableSize
thetableindex kvpair;
return true;
return false;
template
bool Table::removeconst Key aKey
Implement remove function
return false;
template
T Table::lookUpconst Key aKey
Implement lookUp function
return T;
template
Table::Tableconst Table& initTable
Implement copy constructor
template
Table::~Table
Implement destructor
template
Table& Table::operatorconst Table& initTable
Implement assignment operator
return this;
#endif This is "pair.h #pragma once
#ifndef PAIRH
#define PAIRH
template
class Pair
public:
T first;
T second;
Pair : firstT secondT
Pairconst T v const T v : firstv secondv
Pairconst Pair& X : firstXfirst secondXsecond
Pair& operatorconst Pair& init return this Pairinit;
friend bool operatorconst Pair& lhs const Pair& rhs return lhsfirst rhsfirst rhsfirst lhsfirst && lhssecond rhssecond;
friend bool operatorconst Pair& lhs const Pair& rhs return lhsfirst rhsfirst && lhssecond rhssecond;
template
friend Pair makePairconst U& v const U& v;
;
template
Pair makePairconst T& v const T& v
return Pairv v;
#endif This is "Driver.cpp #include
#include "pair.h
#include "table.h
#include "tableSpecificOpsh
using namespace std;
int main
Create an instance of Table with size and mapping function f
Table t f;
Insert keyvalue pairs
Pair pa;
Pair pb;
Pair pc;
tinsertp;
tinsertp;
tinsertp;
Print the table
tprint;
return ;
This is my Output Coming Wrong LOOK :
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started