Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

i was trying to test the pair class but i keep getting this error. there arent any error when i just put everything in one

i was trying to test the pair class but i keep getting this error.

there arent any error when i just put everything in one cpp file.

ld: symbol(s) not found for architecture x86_64

#include

#include "Pair.h"

#include "LinkList.h"

int main()

{

Pair q(1,1.2);

q.setFirst(10);

q.setSecond(1.11);

std::cout<< q.getFirst() << std::endl << q.getSecond();

return 0;

}

#ifndef PAIR_H_

#define PAIR_H_

template

class Pair{

public:

Pair(F,S);

F getFirst();

S getSecond();

void setFirst(F);

void setSecond(S);

private:

F first;

S second;

};

#endif /* PAIR_H_ */

#include "Pair.h"

template

Pair::Pair(F first,S second)

{

this-> first = first;

this-> second = second;

}

template

F Pair::getFirst()

{

return this->first;

}

template

S Pair::getSecond()

{

return this->second;

}

template

void Pair::setFirst(F first)

{

this->first = first;

}

template

void Pair::setSecond(S second)

{

this->second = second;

}

#ifndef LINKLIST_H_

#define LINKLIST_H_

template

class Node{

public:

void setNode(T node)

{

this->node = node;

};

void setLast()

{

this->node = '\0';

};

void setNext(Node * next)

{

this->node = next;

};

Node getNode()

{

return this->node;

};

private:

Node* node;

};

template

class LinkList{

public:

void addFront(T);

void addRear(T);

void insert(Node*, T);

void dele(Node*);

T find(Node*);

LinkList(T);

private:

Node head;

Node next;

};

#endif /* LINKLIST_H_ */

#include "LinkList.h"

template

LinkList::LinkList()

{

this->head = '/0';

this->next = '/0';

}

template

void LinkList::addRear(T obj)

{

if(head == '/0')

{

head = new Node;

head->setNode(obj);

next = head;

}

else

{

Node temp;

temp->setNode(obj);

temp->setLast();

next->setNext(temp);

next = next->getNode();

}

}

template

void LinkList::addFront(T obj)

{

if(head == '/0')

{

head = new Node;

head->setNode(obj);

next = head;

}

else

{

Node temp;

temp->setNode(obj);

temp->setLast(head);

head = temp;

}

}

template

void LinkList::insert(Node* node, T obj)

{

Node temp = new Node;

temp->setNode(obj);

temp->setNext(node->getNode());

node->setNext(temp);

}

template

void LinkList::dele(Node* node)

{

Node temp = new Node;

temp = head;

while(temp->getNode() != node && temp->getNode())

{

temp = temp->getNode;

}

if(temp)

{

temp->setNext(node->getNode());

delete node;

}

}

template

T LinkList::find(Node* head)

{

int size = 0;

Node temp = new Node;

temp = head;

while(temp)

{

size++;

temp = temp->getNode();

}

return size;

}

heres my code

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

Computer Aided Database Design

Authors: Antonio Albano, Valeria De Antonellis, A. Di Leva

1st Edition

0444877355, 978-0444877352

More Books

Students also viewed these Databases questions