Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help with this lab my code is not working ? ? ? Please use this code and correct it whatever are there worng

I need help with this lab my code is not working ??? Please use this code and correct it whatever are there worng !!! Run the code show its work successfully !!! I need all the code which you are going use to run the program !!! I need all the code & output too which show as program work successfully !!! Please I need Full code and output and Thank You !!! 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 MY Code : "pair.h " #pragma once
#ifndef PAIR_H
#define PAIR_H
template
class Pair {
public:
T1 first;
T2 second;
Pair() : first(T1()), second(T2()){}
Pair(const T1 v1, const T2 v2) : first(v1), second(v2){}
template
Pair(const Pair& X) : first(X.first), second(X.second){}
template
Pair& operator=(const Pair& init){
return *this = Pair(init);
}
friend bool operator(const Pair& lhs, const Pair& rhs){
return lhs.first rhs.first ||(!(rhs.first lhs.first) && lhs.second rhs.second);
}
friend bool operator==(const Pair& lhs, const Pair& rhs){
return lhs.first == rhs.first && lhs.second == rhs.second;
}
};
template
Pair makePair(const T1& v1, const T2& v2){
return Pair(v1, v2);
}
#endif My next code "table.h" #pragma once
#ifndef TABLE_H
#define TABLE_H
#include
#include "pair.h"
template
class Table {
public:
typedef Key key_type;
private:
int tableSize;
Pair* the_table;
int (*Mapping)(Key k);
public:
void print();
Table(int n, int (*map)(Key k));
bool insert(Pair kvpair);
bool remove(const Key aKey);
T lookUp(const Key aKey);
Table(const Table& initTable);
~Table();
Table& operator=(const Table& initTable);
};
#include "table.t"
#endif My code "table.t" #ifndef TABLE_T
#define TABLE_T
#include "table.h"
template
void Table::print(){
for (int i =0; i tableSize; ++i){
std::cout the_table[i].first ": " the_table[i].second std::endl;
}
}
template
Table::Table(int n, int (*map)(Key k)) : tableSize(n), Mapping(map){
the_table = new Pair[tableSize];
}
template
bool Table::insert(Pair kvpair){
int index = Mapping(kvpair.first);
if (index >=0 && index tableSize){
the_table[index]= kvpair;
return true;
}
return false;
#endif This is my "tableSpecificOps1.cpp" #include "tableSpecificOps1.h"
#include "tableSpecificOps1.h"
int f(char c){
// Function body
return c;
}
int f1(double d){
// Function body
return d;
} This is my "tableSpecificOps1.h" #pragma once
#ifndef TABLE_SPCIFIC1_H
#define TABLE_SPCIFIC1_H
int f(char c);
int f1(double d);
#endif This is my Driver.cpp screenshot
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

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

Algorithmic Trading Navigating The Digital Frontier

Authors: Alex Thompson

1st Edition

B0CHXR6CXX, 979-8223284987

More Books

Students also viewed these Databases questions

Question

Which form of proof do you find most persuasive? Why?

Answered: 1 week ago