Question: C++ DATA STRUCTURES I can't complete part B of the project (I just need part b) . I get 6 errors related to the same

C++ DATA STRUCTURES

I can't complete part B of the project (I just need part b). I get 6 errors related to the same line (I would highlight and comment in the line that I get the error).

The error I get are:

(14): error C2143: syntax error: missing ';' before '<' (24): note: see reference to class template instantiation 'UnsortedType' being compiled (14): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int h(14): error C2238: unexpected token(s) preceding ';' 1>Source.cpp (14): error C2143: syntax error: missing ';' before '<' (24): note: see reference to class template instantiation 'UnsortedType' being compiled (14): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int (14): error C2238: unexpected token(s) preceding ';'

Program instructions:

An Unsorted Type ADT is to be extended by the addition of function SplitLists, which as the following specifications: SplitLists(UnsortedType list, ItemType item, UnsortedType& list1. UnsortedType& list2) Function: Divideslist into two lists according to the key of item. Preconditions:list has been initialized and is not empty. Post conditions: list1 contains all the items of list whose keys are less than or equal to items key; list2 contains all of the items oflist whose keys are greater than items key. a. Implement SplitLists as an array-based member function of the Unsorted List ADT. b. Implement SplitLists as a linked member function of the Unsorted List ADT.

// header file

#pragma once

#include

template

class UnsortedType {

private:

int length;

vector list; // THE ERRORS I GET COME FROM THIS DECLARATION

public:

UnsortedType(); // constructor

int getLength(); //get length of list

T getListElement(int i);

void putItem(T item);

void show();

};

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// SplitList.cpp

#include

#include "SplitList.h"

using namespace std;

template

UnsortedType::UnsortedType()

{

length = 0;

}

template

int UnsortedType::getLength()

{

return this->length;

}

template

T UnsortedType::getListElement(int i) {

return list.at(i);

}

template

void UnsortedType::putItem(T item) {

list.push_back(item);

length++;

}

template

void UnsortedType::show() {

for (int i = 0; i < length; i++)

cout << "List is: " << list.at(i) << endl;

}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#include

#include "SplitList.h"

using namespace std;

template

void splitLists(UnsortedTypelist, T item,

UnsortedType&list1, UnsortedType&list2)

{

for (int i = 0; i < list.getLength(); i++) {

if (list.getListElement(i) <= item) {

list1.putItem(list.getListElement(i));

}

else

{

list2.putItem(list.getListElement(i));

}

}

}

int main() {

UnsortedType list;

cout << "orignal item list:" << endl;

list.putItem(8);

list.putItem(6.5);

list.putItem(9.6);

list.putItem(4);

list.putItem(3);

list.putItem(2);

list.putItem(10);

list.show();

UnsortedType list1;

UnsortedType < double > list2;

cout << "Split list in two (list1& list2)" << endl;

cout << "list 1: " << endl;

list1.show();

cout << "list 2:" << endl;

list2.show();

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!