Question: Having trouble figuring out why my program keeps crashing this is coded in c++. the error in my IDE is currently syntax error: missing, before

Having trouble figuring out why my program keeps crashing this is coded in c++. the error in my IDE is currently "syntax error: missing"," before '<'" in the "class gVector: public vector" line

//gVector.h

#pragma once

#include

template

class gVector: public vector

{

public:

gVector(int low, int high);

// vector has high - low+1 elements in range [low,high]

T& operator [] (int i);

// operator verifies that lower <= i <= upper.

// if not, it throws the indexRangeError exception

void resize(int lowIndex, int highIndex);

// resize vector and set range to [lowIndex, highIndex]

private:

int lower;

int upper;

};

#include "gVector.cpp"

--------------------------------------------------------------------

//gVector.cpp

#ifndef __G_VECTOR_CPP__

#define __G_VECTOR_CPP__

#include "gVector.h"

// For all gVector member function definitions, utilize base class vector

template

//You must implement utilize vectors constructor(s)

gVector::gVector(int low, int high) {

vector(low, high);

lower = low;

upper = high;

}

//Override vectors []

//You must implement

template

T& gVector::operator[] (int i) {

if ((i < lower) || (i > upper)) {

throw indexRangeError("index range error", i, size());

}

else {

return gVector::operator[](i - lower);

}

}

//Overload vectors resize

//You must implement

template

void gVector::resize(int lowIndex, int highIndex) {

if (!(low <= high)) {

int temp;

temp = low;

low = high;

high = temp;

}

else {

vector.resize(highIndex - lowIndex + 1);

lower = lowIndex;

upper = highIndex;

}

}

#endif

-------------------------------------------------------------------------

//mainDriver.cpp

#include

#include "gVector.h" //use gVector class

#include "CS255_Exceptions.h"

using namespace std;

int main() {

// this test declares and defines two types of gVector objects

const int MIN_TEMP = -10;

const int MAX_TEMP = 15;

gVector code('A', 'Z');

gVector fahrVector{ MIN_TEMP, MAX_TEMP }; //Alternate way of calling constructor

// a very simple encryption of upper-case Latin letters

for (char ch = 'A'; ch <= 'Z'; ch++)

code[ch] = ch + 5;

// tempVector [cel_temp] holds Fahrenheit equivalent of Celsius

// temperature cel_temp. Conversion is F = 9/5 C + 32

for (int cel_temp = MIN_TEMP; cel_temp <= MAX_TEMP; cel_temp++)

fahrVector[cel_temp] = 9.0 / 5.0*cel_temp + 32.0;

// Show simple encryption shift

cout << "Encryption Shift:" << endl;

for (char ch = 'A'; ch <= 'Z'; ch++)

cout << ch;

cout << endl;

for (char ch = 'A'; ch <= 'Z'; ch++)

cout << code[ch];

cout << endl << endl;

// output the temperature conversions

cout << "Temperature Conversion C - > F:" << endl;

cout << " C" << " " << "F" << endl;

for (int cel_temp = MIN_TEMP; cel_temp <= MAX_TEMP; cel_temp++) {

cout.setf(ios::fixed, ios::floatfield);

cout.precision(2);

cout.width(7);

cout << cel_temp << " " << fahrVector[cel_temp] << endl;

}

return 0;

}

--------------------------------------------------------------------------------------

#pragma once

#ifndef __CS255_EXCEPTION_CLASSES__

#define __CS255_EXCEPTION_CLASSES__

#include

#include

using namespace std;

class baseException

{

public:

baseException(const string& str = "") :

msgString(str)

{

if (msgString == "")

msgString = "Unspecified exception";

}

string what() const

{

return msgString;

}

// protected allows a derived class to access msgString.

protected:

string msgString;

};

// failure to allocate memory (new() returns NULL)

class memoryAllocationError : public baseException

{

public:

memoryAllocationError(const string& msg = "") :

baseException(msg)

{}

};

// function argument out of proper range

class rangeError : public baseException

{

public:

rangeError(const string& msg = "") :

baseException(msg)

{}

};

// index out of range

class indexRangeError : public baseException

{

public:

indexRangeError(const string& msg, int i, int size) :

baseException()

{

ostringstream indexErr;

indexErr << msg << " index " << i << " size = " << size << ends;

// indexRangeError can modify msgString, since it is in

// the protected section of baseException

msgString = indexErr.str();

}

};

// attempt to erase from an empty container

class underflowError : public baseException

{

public:

underflowError(const string& msg = "") :

baseException(msg)

{}

};

// attempt to insert into a full container

class overflowError : public baseException

{

public:

overflowError(const string& msg = "") :

baseException(msg)

{}

};

// error in expression evaluation

class expressionError : public baseException

{

public:

expressionError(const string& msg = "") :

baseException(msg)

{}

};

// bad object reference

class referenceError : public baseException

{

public:

referenceError(const string& msg = "") :

baseException(msg)

{}

};

// feature not implemented

class notImplementedError : public baseException

{

public:

notImplementedError(const string& msg = "") :

baseException(msg)

{}

};

// date errors

class dateError : public baseException

{

public:

dateError(const string& first, int v, const string& last) :

baseException()

{

ostringstream dateErr;

dateErr << first << ' ' << v << ' ' << last << ends;

// dateError can modify msgString, since it is in

// the protected section of baseException

msgString = dateErr.str();

}

};

// error in graph class

class graphError : public baseException

{

public:

graphError(const string& msg = "") :

baseException(msg)

{}

};

// file open error

class fileOpenError : public baseException

{

public:

fileOpenError(const string& fname) :

baseException()

{

ostringstream fileErr;

fileErr << "Cannot open \"" << fname << "\"" << ends;

// fileOpenError can modify msgString, since it is in

// the protected section of baseException

msgString = fileErr.str();

}

};

// error in graph class

class fileError : public baseException

{

public:

fileError(const string& msg = "") :

baseException(msg)

{}

};

#endif // __CS255_EXCEPTION_CLASSES__

-----------------------------------------------------------------------------------------

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!