Answered step by step
Verified Expert Solution
Link Copied!

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 ( 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) I'm provided my file : "tableSpecificOps1.h" #pragma once #ifndef TABLE_SPCIFIC1_H
#define TABLE_SPCIFIC1_H
int f(char c);
int f1(double d);
#endif This is "tableSpecificOps1.cpp" #include "tableSpecificOps1.h"
int f(char c)
{/*Function body */ return c; }
int f1(double d)
{/*Function body*/ return d; } This is // "table.h" #pragma once
#ifndef TABLE_H
#define TABLE_H
#include
#include "pair.h"
template
class Table {
public:
typedef T 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 This is "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;
}
template
bool Table::remove(const Key aKey){
// Implement remove function
return false;
}
template
T Table::lookUp(const Key aKey){
// Implement lookUp function
return T();
}
template
Table::Table(const Table& initTable){
// Implement copy constructor
}
template
Table::~Table(){
// Implement destructor
}
template
Table& Table::operator=(const Table& initTable){
// Implement assignment operator
return *this;
}
#endif This is "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){}
Pair(const Pair& X) : first(X.first), second(X.second){}
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
friend Pair makePair(const U1& v1, const U2& v2);
};
template
Pair makePair(const T1& v1, const T2& v2){
return Pair(v1, v2);
}
#endif This is "Driver.cpp" #include
#include "pair.h"
#include "table.h"
#include "tableSpecificOps1.h"
using namespace std;
int main(){
// Create an instance of Table with size 7 and mapping function f
Table t(7, f);
// Insert key-value pairs
Pair p1('a',222);
Pair p2('b',123);
Pair p3('c',456);
t.insert(p1);
t.insert(p2);
t.insert(p3);
// Print the table
t.print();
return 0;
} This is my Output Coming Wrong LOOK :sshh
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

Expert Oracle9i Database Administration

Authors: Sam R. Alapati

1st Edition

1590590228, 978-1590590225

Students also viewed these Databases questions

Question

How do Excel Pivot Tables handle data from non OLAP databases?

Answered: 1 week ago