Customize Linked list to store custom objects in C++
Budget: $10 – $30 USD
I am working on a template project. I have hit a roadblock, I cannot figure out what's wrong with my code the error code is "undefined reference to" so please look at the code I have so far and complete the requirements I have asked to fulfill. I have a rectangle class with 3 variables, length, width, and area. I want to build a program that can take rectangle class as a template object. if it doesn't make sense please refer to the code and the file, I have so far and it should make sense what I'm trying to do.
use this set of numbers and characters to get the exact output as provided in the file
7 2 a
3 4 a
4 5 a
3 5 d
2 6 a
4 4 a
12 1 D
2 8 a
8 2 d
******* tsllist.h ******
#ifndef INT_LINKED_LIST
#define INT_LINKED_LIST
#include <iostream>
template <class T>
class TSLList {
public:
// Constructor
TSLList() {
head = nullptr;
}
//D Destructor
// ~TSLList() {
// clearList();
// }
// prints the info content and address of each node in the list
void printAll() const {
for (TSLLNode *tmp = head; tmp != nullptr; tmp = tmp->next)
std::cout << "->[" << tmp->info << "," << tmp << "]";
std::cout << std::endl;
}
// Inserts node in order (see assignment specification for details)
void insertInOrder(T);
// Deletes an occurrence of argument (see assignment specification for details)
T deleteVal(T);
// Deletes all occurrences of argument (see assignment specification for details)
void deleteAllVal(T el);
// Clears the list (deallocates memory - see assignment specification for details)
void clearList();
private:
// Node stored in linked list
struct TSLLNode {
TSLLNode(T el = T()) {
info = el;
next = nullptr;
}
T info;
TSLLNode *next;
};
TSLLNode *head; // head of the list
};
#endif
********rectangle.h*******
#ifndef RECTANGLE_H
#define RECTANGLE_H
#include <iostream>
using std::ostream;
class Rectangle
{
public:
Rectangle(int l = 0, int w = 0) // default constructor
{ length = l; width = w; area = length * width; }
void setLength(int l) // lengthgth mutator (setter) - updates area member
{ length = l; area = length * width; }
void setWidth(int w) // width mutator (setter) - updates area member
{ width = w; area = length * width; }
int getLength() const // lengthgth accessor (getter)
{ return length; }
int getWidth() const // width accessor (getter)
{ return width; }
int getArea() const // area accessor (getter)
{ return area; }
friend ostream& operator << (ostream& os, const Rectangle & rect) // outputs a Rectangle object
{
os << "[L:" << rect.length << " W:" << rect.width << " (A " << rect.area << ")]";
return os;
}
// implement overloads below
bool operator<(const Rectangle &);
bool operator<=(const Rectangle &);
bool operator>(const Rectangle &);
bool operator>=(const Rectangle &);
bool operator==(const Rectangle &);
bool operator!=(const Rectangle &);
private:
int length; // length data member
int width; // width data member
int area; // area data member
};
#endif
****the specification file and my implementation files are provided, please complete the project based on these specifications and fix the implementation if necessary.****
use this set of numbers and characters to get the exact output as provided in the file
7 2 a
3 4 a
4 5 a
3 5 d
2 6 a
4 4 a
12 1 D
2 8 a
8 2 d
******* tsllist.h ******
#ifndef INT_LINKED_LIST
#define INT_LINKED_LIST
#include <iostream>
template <class T>
class TSLList {
public:
// Constructor
TSLList() {
head = nullptr;
}
//D Destructor
// ~TSLList() {
// clearList();
// }
// prints the info content and address of each node in the list
void printAll() const {
for (TSLLNode *tmp = head; tmp != nullptr; tmp = tmp->next)
std::cout << "->[" << tmp->info << "," << tmp << "]";
std::cout << std::endl;
}
// Inserts node in order (see assignment specification for details)
void insertInOrder(T);
// Deletes an occurrence of argument (see assignment specification for details)
T deleteVal(T);
// Deletes all occurrences of argument (see assignment specification for details)
void deleteAllVal(T el);
// Clears the list (deallocates memory - see assignment specification for details)
void clearList();
private:
// Node stored in linked list
struct TSLLNode {
TSLLNode(T el = T()) {
info = el;
next = nullptr;
}
T info;
TSLLNode *next;
};
TSLLNode *head; // head of the list
};
#endif
********rectangle.h*******
#ifndef RECTANGLE_H
#define RECTANGLE_H
#include <iostream>
using std::ostream;
class Rectangle
{
public:
Rectangle(int l = 0, int w = 0) // default constructor
{ length = l; width = w; area = length * width; }
void setLength(int l) // lengthgth mutator (setter) - updates area member
{ length = l; area = length * width; }
void setWidth(int w) // width mutator (setter) - updates area member
{ width = w; area = length * width; }
int getLength() const // lengthgth accessor (getter)
{ return length; }
int getWidth() const // width accessor (getter)
{ return width; }
int getArea() const // area accessor (getter)
{ return area; }
friend ostream& operator << (ostream& os, const Rectangle & rect) // outputs a Rectangle object
{
os << "[L:" << rect.length << " W:" << rect.width << " (A " << rect.area << ")]";
return os;
}
// implement overloads below
bool operator<(const Rectangle &);
bool operator<=(const Rectangle &);
bool operator>(const Rectangle &);
bool operator>=(const Rectangle &);
bool operator==(const Rectangle &);
bool operator!=(const Rectangle &);
private:
int length; // length data member
int width; // width data member
int area; // area data member
};
#endif
****the specification file and my implementation files are provided, please complete the project based on these specifications and fix the implementation if necessary.****