SlideShare a Scribd company logo
1 of 8
I am trying to fill out a program where the method definitions will be written underthe .h file
the following attributes in the .h file are
When I run my program I get these errors. Is there anyway to fix these issues?
the program
--main cpp--
#include "vector.h"
#include <iostream>
#include <string>
#include <fstream>
#include <cassert>
#include <sstream>
using namespace std;
int main()
{
/*
Type your test code here.
You will not be submitting this code. It's only for testing.
*/
return 0;
}
vector.h
/ / vector class template
#ifndef Vector_Vector_h
#define Vector_Vector_h
#include <iostream>
#include <new> // Needed for bad_alloc exception
#include <cstdlib> // Needed for the exit function
#include <stdexcept>
namespace CIST2362 {
template<class T>
class vector {
private:
T *aptr; // To point to the allocated array
unsigned long arraySize; // Number of elements in the array
unsigned long arrayCapacity; // number of memory locations available to the vector
// increase capacity
void increaseCapacity(unsigned long);
public:
// Default constructor
vector();
// Constructor declaration
vector(unsigned long);
// Resize the vector - changes the size attribute
void resize(unsigned long n);
// Resizes the vector and initializes the unused locations - updates the size attribute
void resize(unsigned long n, const T &val);
// Copy constructor declaration
vector(const vector &);
// Destructor declaration
~vector();
// Accessor to return the array size
unsigned long size() const;
// Accessor to return the array capacity
unsigned long capacity() const;
// Accessor to test empty status
bool empty() const;
// Accessor to return a specific element
T &at(int position);
// Overloaded [] operator declaration
T &operator[](const int &);
// back element of the vector
T &back();
// front element of the vector
T &front();
void push_back(T); // New push_back member
T pop_back(); // New pop_back member
// insert element at position
int insert(unsigned long, const T &);
// erase a range of values
void erase(unsigned long, unsigned long);
// erase one element at a position
void erase(unsigned long);
};
/* This is where your method definitions will be written. This default constructor
* the first method you need to complete. To compile the program, you should create
* empty stubs for each of the declared methods.
*/
template<class T>
vector<T>::vector() {
}
}
#endif
my code
vector.h
// vector class template
#ifndef Vector_Vector_h
#define Vector_Vector_h
#include <iostream>
#include <new> // Needed for bad_alloc exception
#include <cstdlib> // Needed for the exit function
#include <stdexcept>
namespace CIST2362 {
template<class T>
class vector {
private:
T *aptr; // To point to the allocated array
unsigned long arraySize; // Number of elements in the array
unsigned long arrayCapacity; // number of memory locations available to the vector
// increase capacity
void increaseCapacity(unsigned long);
public:
// Default constructor
vector();
// Constructor declaration
vector(unsigned long);
// Resize the vector - changes the size attribute
void resize(unsigned long n);
// Resizes the vector and initializes the unused locations - updates the size attribute
void resize(unsigned long n, const T &val);
// Copy constructor declaration
vector(const vector &);
// Destructor declaration
~vector();
// Accessor to return the array size
unsigned long size() const;
// Accessor to return the array capacity
unsigned long capacity() const;
// Accessor to test empty status
bool empty() const;
// Accessor to return a specific element
T &at(int position);
// Overloaded [] operator declaration
T &operator[](const int &);
// back element of the vector
T &back();
// front element of the vector
T &front();
void push_back(T); // New push_back member
T pop_back(); // New pop_back member
// insert element at position
int insert(unsigned long, const T &);
// erase a range of values
void erase(unsigned long, unsigned long);
// erase one element at a position
void erase(unsigned long);
};
/* This is where your method definitions will be written. This default constructor
* the first method you need to complete. To compile the program, you should create
* empty stubs for each of the declared methods.
*/
template<class T>
vector<T>::vector() {
arraySize = 0;
arrayCapacity = 10;
aptr = new long[arrayCapacity];
}
vector<T>::vector(unsigned long){
arraySize = size;
arrayCapacity = size;
aptr = new long[arrayCapacity];
}
vector<T>::resize(unsigned long n){
aptr.resize(arrayCapacity)
}
vector<T>::resize(unsigned long n){
aptr.resize(arrayCapacity)
}
vector<T>::resize(unsigned long n, const T &val){
}
vector<T>::vector(const vector &){
arraySize = obj.arraySize;
arrayCapacity = obj.arrayCapacity;
aptr = new long[arrayCapacity];
for (long i = 0; i < arraySize; i++)
aptr[i] = obj.aptr[i]
}
vector<T>::~vector(){
delete [] aptr;
}
vector<T>::unsigned long size(){
return arraySize;
}
vector<T>::unsigned long capacity(){
return arrayCapacity;
}
vector<T>::bool empty()const{
if (T.empty()){
bool T.empty() = true;
}else false;
}
vector<T>::T &at(int position){
if( position <0 || position >=arraySize)
{
std::cout << "ERROR: Subscript out of range.n";
}
return aptr[position];
}
vector<T>::T &operator[](const int &){
return aptr[];
}
vector<T>::T &back(){
T.back(arrayCapacity);
}
vector<T>::T &front(){
T.front(arrayCapacity);
}
vector<T>::arraySize(T){
if (arraySize == arrayCapacity)
{
arrayCapacity += arraySize;
int *temp = new long[arrayCapacity];
for (long i = -1; i < arraySize; i++){
temp[i] = aptrPtr[i];
delete[] aptrPtr;
aptr = temp;
}
aptrPtr[arraySize] = T;
arraySize++;
}
vector<T>::T pop_back(){
return aptrPtr[--arraySize];
}
vector<T>::insert(unsigned long, const T &){
T.insert (position,arrayCapacity);
}
vector<T>::erase(unsigned long, unsigned long){
T.erase (position,arrayCapacity);
}
vector<T>::erase(unsigned long){
T.erase (position);
}
}
#endif
- T*aptr. The pointer being used for the internal array maintained by the vector class. You may
change this name if you want :) - T &at(int): access the element at the given index and throws
an - unsigned long arraySize: The value that represents the current number exception if out of
bounds of elements in the vector - T &operator[](const int &): access the element at the given
index - unsigned long arrayCapacity: The value that represents the current and does not check
bounds for efficiency purposes. allocated memory capacity of the vector (must always be >=
arraySize) - T &back(): access the last element in the vector - T &front(): access the first
element in the vector You will find the following private method: Modifying methods: - void
increaseCapacity(unsigned long): This method is used for - void push_back(T): adds an element
to the end of the vector increasing the capacity of the vector. It should not be public, but other
methods in the class would need it. NOTE: You may add more private methods if you see
opportunities for code reuse across the needs of the - T pop_back(): removes the last element of
the vector and returns it public vector methods. - int insert(unsigned long, const T &): Inserts the
element in the 2nd parameter at the position given by the 1st parameter - void erase(unsigned
long, unsigned long): Removes the elements starting with the element at the position of the first
parameter up to the You will find the following public methods: There are 3 constructors.
element before the position in the 2nd parameter i.e. do not remove the - vector(): This
constructor creates a vector with a capacity of 10 and size element at the position of the 2nd
parameter. of 0 . - vector(unsigned long): This constructor creates a vector with the capacity
given by the parameter and size will be 0 . - vector(const vector &): This is the copy constructor
for the class There 2 resize methods: - void resize(unsigned long n ): Resize the vector based on
this parameter. Resize can make it smaller or larger; if it's made smaller the capacity is
unchanged (makes the vector more efficient). - void resize(unsigned long n , const T &): Resize
the vector, and if it's made larger then fill in the new elements with value of the 2 nd parameter.
The destructor: vector(): This needs to clean up all memory allocated to the vector Accessor
methods: - unsigned long size() const: returns the size attribute of the vector - unsigned long
capacity() const: returns the capacity attribute of the vector - bool empty() const returns true if
the vector is empty, and false otherwise vector.h:141:9: error: template argument 1 is invalid

More Related Content

Similar to I am trying to fill out a program where the method definitions will b.docx

3 functions and class
3   functions and class3   functions and class
3 functions and classtrixiacruz
 
Intro to C# - part 2.pptx emerging technology
Intro to C# - part 2.pptx emerging technologyIntro to C# - part 2.pptx emerging technology
Intro to C# - part 2.pptx emerging technologyworldchannel
 
Please the following is the currency class of perious one- class Curre.pdf
Please the following is the currency class of perious one- class Curre.pdfPlease the following is the currency class of perious one- class Curre.pdf
Please the following is the currency class of perious one- class Curre.pdfadmin463580
 
C++11 - A Change in Style - v2.0
C++11 - A Change in Style - v2.0C++11 - A Change in Style - v2.0
C++11 - A Change in Style - v2.0Yaser Zhian
 
Getting StartedCreate a class called Lab8. Use the same setup for .pdf
Getting StartedCreate a class called Lab8. Use the same setup for .pdfGetting StartedCreate a class called Lab8. Use the same setup for .pdf
Getting StartedCreate a class called Lab8. Use the same setup for .pdfinfo309708
 
C++ Please write the whole code that is needed for this assignment- wr.docx
C++ Please write the whole code that is needed for this assignment- wr.docxC++ Please write the whole code that is needed for this assignment- wr.docx
C++ Please write the whole code that is needed for this assignment- wr.docxBrianGHiNewmanv
 
In C++ please, do not alter node.hStep 1 Inspect the Node.h file.pdf
In C++ please, do not alter node.hStep 1 Inspect the Node.h file.pdfIn C++ please, do not alter node.hStep 1 Inspect the Node.h file.pdf
In C++ please, do not alter node.hStep 1 Inspect the Node.h file.pdfstopgolook
 
PYTHON-PROGRAMMING-UNIT-II (1).pptx
PYTHON-PROGRAMMING-UNIT-II (1).pptxPYTHON-PROGRAMMING-UNIT-II (1).pptx
PYTHON-PROGRAMMING-UNIT-II (1).pptxgeorgejustymirobi1
 
16858 memory management2
16858 memory management216858 memory management2
16858 memory management2Aanand Singh
 
C++ STL (quickest way to learn, even for absolute beginners).pptx
C++ STL (quickest way to learn, even for absolute beginners).pptxC++ STL (quickest way to learn, even for absolute beginners).pptx
C++ STL (quickest way to learn, even for absolute beginners).pptxAbhishek Tirkey
 
C++ STL (quickest way to learn, even for absolute beginners).pptx
C++ STL (quickest way to learn, even for absolute beginners).pptxC++ STL (quickest way to learn, even for absolute beginners).pptx
C++ STL (quickest way to learn, even for absolute beginners).pptxGauravPandey43518
 
Consider this code using the ArrayBag of Section 5.2 and the Locat.docx
Consider this code using the ArrayBag of Section 5.2 and the Locat.docxConsider this code using the ArrayBag of Section 5.2 and the Locat.docx
Consider this code using the ArrayBag of Section 5.2 and the Locat.docxmaxinesmith73660
 
C++ Programming Homework Help
C++ Programming Homework HelpC++ Programming Homework Help
C++ Programming Homework HelpC++ Homework Help
 
Algorithms devised for a google interview
Algorithms devised for a google interviewAlgorithms devised for a google interview
Algorithms devised for a google interviewRussell Childs
 
Resource wrappers in C++
Resource wrappers in C++Resource wrappers in C++
Resource wrappers in C++Ilio Catallo
 
Objectives Assignment 09 Applications of Stacks COS.docx
Objectives Assignment 09 Applications of Stacks COS.docxObjectives Assignment 09 Applications of Stacks COS.docx
Objectives Assignment 09 Applications of Stacks COS.docxdunhamadell
 
Java: Introduction to Arrays
Java: Introduction to ArraysJava: Introduction to Arrays
Java: Introduction to ArraysTareq Hasan
 

Similar to I am trying to fill out a program where the method definitions will b.docx (20)

Memory Management In C++
Memory Management In C++Memory Management In C++
Memory Management In C++
 
3 functions and class
3   functions and class3   functions and class
3 functions and class
 
Intro to C# - part 2.pptx emerging technology
Intro to C# - part 2.pptx emerging technologyIntro to C# - part 2.pptx emerging technology
Intro to C# - part 2.pptx emerging technology
 
Arrays
ArraysArrays
Arrays
 
Please the following is the currency class of perious one- class Curre.pdf
Please the following is the currency class of perious one- class Curre.pdfPlease the following is the currency class of perious one- class Curre.pdf
Please the following is the currency class of perious one- class Curre.pdf
 
C++11 - A Change in Style - v2.0
C++11 - A Change in Style - v2.0C++11 - A Change in Style - v2.0
C++11 - A Change in Style - v2.0
 
Getting StartedCreate a class called Lab8. Use the same setup for .pdf
Getting StartedCreate a class called Lab8. Use the same setup for .pdfGetting StartedCreate a class called Lab8. Use the same setup for .pdf
Getting StartedCreate a class called Lab8. Use the same setup for .pdf
 
C++ Please write the whole code that is needed for this assignment- wr.docx
C++ Please write the whole code that is needed for this assignment- wr.docxC++ Please write the whole code that is needed for this assignment- wr.docx
C++ Please write the whole code that is needed for this assignment- wr.docx
 
CPP Homework Help
CPP Homework HelpCPP Homework Help
CPP Homework Help
 
In C++ please, do not alter node.hStep 1 Inspect the Node.h file.pdf
In C++ please, do not alter node.hStep 1 Inspect the Node.h file.pdfIn C++ please, do not alter node.hStep 1 Inspect the Node.h file.pdf
In C++ please, do not alter node.hStep 1 Inspect the Node.h file.pdf
 
PYTHON-PROGRAMMING-UNIT-II (1).pptx
PYTHON-PROGRAMMING-UNIT-II (1).pptxPYTHON-PROGRAMMING-UNIT-II (1).pptx
PYTHON-PROGRAMMING-UNIT-II (1).pptx
 
16858 memory management2
16858 memory management216858 memory management2
16858 memory management2
 
C++ STL (quickest way to learn, even for absolute beginners).pptx
C++ STL (quickest way to learn, even for absolute beginners).pptxC++ STL (quickest way to learn, even for absolute beginners).pptx
C++ STL (quickest way to learn, even for absolute beginners).pptx
 
C++ STL (quickest way to learn, even for absolute beginners).pptx
C++ STL (quickest way to learn, even for absolute beginners).pptxC++ STL (quickest way to learn, even for absolute beginners).pptx
C++ STL (quickest way to learn, even for absolute beginners).pptx
 
Consider this code using the ArrayBag of Section 5.2 and the Locat.docx
Consider this code using the ArrayBag of Section 5.2 and the Locat.docxConsider this code using the ArrayBag of Section 5.2 and the Locat.docx
Consider this code using the ArrayBag of Section 5.2 and the Locat.docx
 
C++ Programming Homework Help
C++ Programming Homework HelpC++ Programming Homework Help
C++ Programming Homework Help
 
Algorithms devised for a google interview
Algorithms devised for a google interviewAlgorithms devised for a google interview
Algorithms devised for a google interview
 
Resource wrappers in C++
Resource wrappers in C++Resource wrappers in C++
Resource wrappers in C++
 
Objectives Assignment 09 Applications of Stacks COS.docx
Objectives Assignment 09 Applications of Stacks COS.docxObjectives Assignment 09 Applications of Stacks COS.docx
Objectives Assignment 09 Applications of Stacks COS.docx
 
Java: Introduction to Arrays
Java: Introduction to ArraysJava: Introduction to Arrays
Java: Introduction to Arrays
 

More from Phil4IDBrownh

I have also tried only B-C-D-E I got it wrong- Which ones are the corr.docx
I have also tried only B-C-D-E I got it wrong- Which ones are the corr.docxI have also tried only B-C-D-E I got it wrong- Which ones are the corr.docx
I have also tried only B-C-D-E I got it wrong- Which ones are the corr.docxPhil4IDBrownh
 
I have also tried these combinations which apparently where wrong B-C-.docx
I have also tried these combinations which apparently where wrong B-C-.docxI have also tried these combinations which apparently where wrong B-C-.docx
I have also tried these combinations which apparently where wrong B-C-.docxPhil4IDBrownh
 
I am looking at satellite images- I come across one and say that there.docx
I am looking at satellite images- I come across one and say that there.docxI am looking at satellite images- I come across one and say that there.docx
I am looking at satellite images- I come across one and say that there.docxPhil4IDBrownh
 
I am having trouble with the math- Emily- who is single- has been offe.docx
I am having trouble with the math- Emily- who is single- has been offe.docxI am having trouble with the math- Emily- who is single- has been offe.docx
I am having trouble with the math- Emily- who is single- has been offe.docxPhil4IDBrownh
 
Human Relations Planning Consider that the human resource manager of y.docx
Human Relations Planning Consider that the human resource manager of y.docxHuman Relations Planning Consider that the human resource manager of y.docx
Human Relations Planning Consider that the human resource manager of y.docxPhil4IDBrownh
 
HTML- CSS- Javascript- React- Redux--- Questions- 1- SASS and LESS 2-.docx
HTML- CSS- Javascript- React- Redux--- Questions- 1- SASS and LESS  2-.docxHTML- CSS- Javascript- React- Redux--- Questions- 1- SASS and LESS  2-.docx
HTML- CSS- Javascript- React- Redux--- Questions- 1- SASS and LESS 2-.docxPhil4IDBrownh
 
Huckvale Corporation manufactures custom cabinets for kitchens- It use (2).docx
Huckvale Corporation manufactures custom cabinets for kitchens- It use (2).docxHuckvale Corporation manufactures custom cabinets for kitchens- It use (2).docx
Huckvale Corporation manufactures custom cabinets for kitchens- It use (2).docxPhil4IDBrownh
 
Huckvale Corporation manufactures custom cabinets for kitchens- It use (1).docx
Huckvale Corporation manufactures custom cabinets for kitchens- It use (1).docxHuckvale Corporation manufactures custom cabinets for kitchens- It use (1).docx
Huckvale Corporation manufactures custom cabinets for kitchens- It use (1).docxPhil4IDBrownh
 
Huckvale Corporation manufactures custom cabinets for kitchens- It use.docx
Huckvale Corporation manufactures custom cabinets for kitchens- It use.docxHuckvale Corporation manufactures custom cabinets for kitchens- It use.docx
Huckvale Corporation manufactures custom cabinets for kitchens- It use.docxPhil4IDBrownh
 
Hypertrophy May be reversible Is organ growth due to increased cell ce.docx
Hypertrophy May be reversible Is organ growth due to increased cell ce.docxHypertrophy May be reversible Is organ growth due to increased cell ce.docx
Hypertrophy May be reversible Is organ growth due to increased cell ce.docxPhil4IDBrownh
 
Human Resource Management ed 16- Chapter 12- page 445 Houston is among.docx
Human Resource Management ed 16- Chapter 12- page 445 Houston is among.docxHuman Resource Management ed 16- Chapter 12- page 445 Houston is among.docx
Human Resource Management ed 16- Chapter 12- page 445 Houston is among.docxPhil4IDBrownh
 
HPRS 2201 Chapter 4- Endocrine System Diseases and Disorders Course Ob.docx
HPRS 2201 Chapter 4- Endocrine System Diseases and Disorders Course Ob.docxHPRS 2201 Chapter 4- Endocrine System Diseases and Disorders Course Ob.docx
HPRS 2201 Chapter 4- Endocrine System Diseases and Disorders Course Ob.docxPhil4IDBrownh
 
I'm not sure how to go about using the RE expression and finding the m.docx
I'm not sure how to go about using the RE expression and finding the m.docxI'm not sure how to go about using the RE expression and finding the m.docx
I'm not sure how to go about using the RE expression and finding the m.docxPhil4IDBrownh
 
I was excited about my new assignment on a special department project-.docx
I was excited about my new assignment on a special department project-.docxI was excited about my new assignment on a special department project-.docx
I was excited about my new assignment on a special department project-.docxPhil4IDBrownh
 
I selected a random sample of 10 individuals who completed the Class S.docx
I selected a random sample of 10 individuals who completed the Class S.docxI selected a random sample of 10 individuals who completed the Class S.docx
I selected a random sample of 10 individuals who completed the Class S.docxPhil4IDBrownh
 
I think 42- 43- and 44 are true- but not too sure- Need help with 41 a.docx
I think 42- 43- and 44 are true- but not too sure- Need help with 41 a.docxI think 42- 43- and 44 are true- but not too sure- Need help with 41 a.docx
I think 42- 43- and 44 are true- but not too sure- Need help with 41 a.docxPhil4IDBrownh
 
I tried doing this myself and got stuck sorting out retained earnings.docx
I tried doing this myself and got stuck sorting out retained earnings.docxI tried doing this myself and got stuck sorting out retained earnings.docx
I tried doing this myself and got stuck sorting out retained earnings.docxPhil4IDBrownh
 
I selected a random sample of 10 individuals who completed the Class S (1).docx
I selected a random sample of 10 individuals who completed the Class S (1).docxI selected a random sample of 10 individuals who completed the Class S (1).docx
I selected a random sample of 10 individuals who completed the Class S (1).docxPhil4IDBrownh
 
How many ways can two items be selected from a group of six items- Use.docx
How many ways can two items be selected from a group of six items- Use.docxHow many ways can two items be selected from a group of six items- Use.docx
How many ways can two items be selected from a group of six items- Use.docxPhil4IDBrownh
 
How many subnetworks in this LAN configuration- POSTE 3C.docx
How many subnetworks in this LAN configuration- POSTE 3C.docxHow many subnetworks in this LAN configuration- POSTE 3C.docx
How many subnetworks in this LAN configuration- POSTE 3C.docxPhil4IDBrownh
 

More from Phil4IDBrownh (20)

I have also tried only B-C-D-E I got it wrong- Which ones are the corr.docx
I have also tried only B-C-D-E I got it wrong- Which ones are the corr.docxI have also tried only B-C-D-E I got it wrong- Which ones are the corr.docx
I have also tried only B-C-D-E I got it wrong- Which ones are the corr.docx
 
I have also tried these combinations which apparently where wrong B-C-.docx
I have also tried these combinations which apparently where wrong B-C-.docxI have also tried these combinations which apparently where wrong B-C-.docx
I have also tried these combinations which apparently where wrong B-C-.docx
 
I am looking at satellite images- I come across one and say that there.docx
I am looking at satellite images- I come across one and say that there.docxI am looking at satellite images- I come across one and say that there.docx
I am looking at satellite images- I come across one and say that there.docx
 
I am having trouble with the math- Emily- who is single- has been offe.docx
I am having trouble with the math- Emily- who is single- has been offe.docxI am having trouble with the math- Emily- who is single- has been offe.docx
I am having trouble with the math- Emily- who is single- has been offe.docx
 
Human Relations Planning Consider that the human resource manager of y.docx
Human Relations Planning Consider that the human resource manager of y.docxHuman Relations Planning Consider that the human resource manager of y.docx
Human Relations Planning Consider that the human resource manager of y.docx
 
HTML- CSS- Javascript- React- Redux--- Questions- 1- SASS and LESS 2-.docx
HTML- CSS- Javascript- React- Redux--- Questions- 1- SASS and LESS  2-.docxHTML- CSS- Javascript- React- Redux--- Questions- 1- SASS and LESS  2-.docx
HTML- CSS- Javascript- React- Redux--- Questions- 1- SASS and LESS 2-.docx
 
Huckvale Corporation manufactures custom cabinets for kitchens- It use (2).docx
Huckvale Corporation manufactures custom cabinets for kitchens- It use (2).docxHuckvale Corporation manufactures custom cabinets for kitchens- It use (2).docx
Huckvale Corporation manufactures custom cabinets for kitchens- It use (2).docx
 
Huckvale Corporation manufactures custom cabinets for kitchens- It use (1).docx
Huckvale Corporation manufactures custom cabinets for kitchens- It use (1).docxHuckvale Corporation manufactures custom cabinets for kitchens- It use (1).docx
Huckvale Corporation manufactures custom cabinets for kitchens- It use (1).docx
 
Huckvale Corporation manufactures custom cabinets for kitchens- It use.docx
Huckvale Corporation manufactures custom cabinets for kitchens- It use.docxHuckvale Corporation manufactures custom cabinets for kitchens- It use.docx
Huckvale Corporation manufactures custom cabinets for kitchens- It use.docx
 
Hypertrophy May be reversible Is organ growth due to increased cell ce.docx
Hypertrophy May be reversible Is organ growth due to increased cell ce.docxHypertrophy May be reversible Is organ growth due to increased cell ce.docx
Hypertrophy May be reversible Is organ growth due to increased cell ce.docx
 
Human Resource Management ed 16- Chapter 12- page 445 Houston is among.docx
Human Resource Management ed 16- Chapter 12- page 445 Houston is among.docxHuman Resource Management ed 16- Chapter 12- page 445 Houston is among.docx
Human Resource Management ed 16- Chapter 12- page 445 Houston is among.docx
 
HPRS 2201 Chapter 4- Endocrine System Diseases and Disorders Course Ob.docx
HPRS 2201 Chapter 4- Endocrine System Diseases and Disorders Course Ob.docxHPRS 2201 Chapter 4- Endocrine System Diseases and Disorders Course Ob.docx
HPRS 2201 Chapter 4- Endocrine System Diseases and Disorders Course Ob.docx
 
I'm not sure how to go about using the RE expression and finding the m.docx
I'm not sure how to go about using the RE expression and finding the m.docxI'm not sure how to go about using the RE expression and finding the m.docx
I'm not sure how to go about using the RE expression and finding the m.docx
 
I was excited about my new assignment on a special department project-.docx
I was excited about my new assignment on a special department project-.docxI was excited about my new assignment on a special department project-.docx
I was excited about my new assignment on a special department project-.docx
 
I selected a random sample of 10 individuals who completed the Class S.docx
I selected a random sample of 10 individuals who completed the Class S.docxI selected a random sample of 10 individuals who completed the Class S.docx
I selected a random sample of 10 individuals who completed the Class S.docx
 
I think 42- 43- and 44 are true- but not too sure- Need help with 41 a.docx
I think 42- 43- and 44 are true- but not too sure- Need help with 41 a.docxI think 42- 43- and 44 are true- but not too sure- Need help with 41 a.docx
I think 42- 43- and 44 are true- but not too sure- Need help with 41 a.docx
 
I tried doing this myself and got stuck sorting out retained earnings.docx
I tried doing this myself and got stuck sorting out retained earnings.docxI tried doing this myself and got stuck sorting out retained earnings.docx
I tried doing this myself and got stuck sorting out retained earnings.docx
 
I selected a random sample of 10 individuals who completed the Class S (1).docx
I selected a random sample of 10 individuals who completed the Class S (1).docxI selected a random sample of 10 individuals who completed the Class S (1).docx
I selected a random sample of 10 individuals who completed the Class S (1).docx
 
How many ways can two items be selected from a group of six items- Use.docx
How many ways can two items be selected from a group of six items- Use.docxHow many ways can two items be selected from a group of six items- Use.docx
How many ways can two items be selected from a group of six items- Use.docx
 
How many subnetworks in this LAN configuration- POSTE 3C.docx
How many subnetworks in this LAN configuration- POSTE 3C.docxHow many subnetworks in this LAN configuration- POSTE 3C.docx
How many subnetworks in this LAN configuration- POSTE 3C.docx
 

Recently uploaded

URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfakmcokerachita
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 

Recently uploaded (20)

URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdf
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 

I am trying to fill out a program where the method definitions will b.docx

  • 1. I am trying to fill out a program where the method definitions will be written underthe .h file the following attributes in the .h file are When I run my program I get these errors. Is there anyway to fix these issues? the program --main cpp-- #include "vector.h" #include <iostream> #include <string> #include <fstream> #include <cassert> #include <sstream> using namespace std; int main() { /* Type your test code here. You will not be submitting this code. It's only for testing. */ return 0; } vector.h / / vector class template #ifndef Vector_Vector_h #define Vector_Vector_h #include <iostream> #include <new> // Needed for bad_alloc exception #include <cstdlib> // Needed for the exit function #include <stdexcept> namespace CIST2362 { template<class T> class vector { private:
  • 2. T *aptr; // To point to the allocated array unsigned long arraySize; // Number of elements in the array unsigned long arrayCapacity; // number of memory locations available to the vector // increase capacity void increaseCapacity(unsigned long); public: // Default constructor vector(); // Constructor declaration vector(unsigned long); // Resize the vector - changes the size attribute void resize(unsigned long n); // Resizes the vector and initializes the unused locations - updates the size attribute void resize(unsigned long n, const T &val); // Copy constructor declaration vector(const vector &); // Destructor declaration ~vector(); // Accessor to return the array size unsigned long size() const; // Accessor to return the array capacity unsigned long capacity() const; // Accessor to test empty status bool empty() const; // Accessor to return a specific element T &at(int position); // Overloaded [] operator declaration T &operator[](const int &); // back element of the vector T &back(); // front element of the vector T &front();
  • 3. void push_back(T); // New push_back member T pop_back(); // New pop_back member // insert element at position int insert(unsigned long, const T &); // erase a range of values void erase(unsigned long, unsigned long); // erase one element at a position void erase(unsigned long); }; /* This is where your method definitions will be written. This default constructor * the first method you need to complete. To compile the program, you should create * empty stubs for each of the declared methods. */ template<class T> vector<T>::vector() { } } #endif my code vector.h // vector class template #ifndef Vector_Vector_h #define Vector_Vector_h #include <iostream> #include <new> // Needed for bad_alloc exception #include <cstdlib> // Needed for the exit function #include <stdexcept> namespace CIST2362 { template<class T> class vector { private: T *aptr; // To point to the allocated array
  • 4. unsigned long arraySize; // Number of elements in the array unsigned long arrayCapacity; // number of memory locations available to the vector // increase capacity void increaseCapacity(unsigned long); public: // Default constructor vector(); // Constructor declaration vector(unsigned long); // Resize the vector - changes the size attribute void resize(unsigned long n); // Resizes the vector and initializes the unused locations - updates the size attribute void resize(unsigned long n, const T &val); // Copy constructor declaration vector(const vector &); // Destructor declaration ~vector(); // Accessor to return the array size unsigned long size() const; // Accessor to return the array capacity unsigned long capacity() const; // Accessor to test empty status bool empty() const; // Accessor to return a specific element T &at(int position); // Overloaded [] operator declaration T &operator[](const int &); // back element of the vector T &back(); // front element of the vector T &front();
  • 5. void push_back(T); // New push_back member T pop_back(); // New pop_back member // insert element at position int insert(unsigned long, const T &); // erase a range of values void erase(unsigned long, unsigned long); // erase one element at a position void erase(unsigned long); }; /* This is where your method definitions will be written. This default constructor * the first method you need to complete. To compile the program, you should create * empty stubs for each of the declared methods. */ template<class T> vector<T>::vector() { arraySize = 0; arrayCapacity = 10; aptr = new long[arrayCapacity]; } vector<T>::vector(unsigned long){ arraySize = size; arrayCapacity = size; aptr = new long[arrayCapacity]; } vector<T>::resize(unsigned long n){ aptr.resize(arrayCapacity) } vector<T>::resize(unsigned long n){ aptr.resize(arrayCapacity) } vector<T>::resize(unsigned long n, const T &val){ } vector<T>::vector(const vector &){ arraySize = obj.arraySize; arrayCapacity = obj.arrayCapacity; aptr = new long[arrayCapacity]; for (long i = 0; i < arraySize; i++) aptr[i] = obj.aptr[i]
  • 6. } vector<T>::~vector(){ delete [] aptr; } vector<T>::unsigned long size(){ return arraySize; } vector<T>::unsigned long capacity(){ return arrayCapacity; } vector<T>::bool empty()const{ if (T.empty()){ bool T.empty() = true; }else false; } vector<T>::T &at(int position){ if( position <0 || position >=arraySize) { std::cout << "ERROR: Subscript out of range.n"; } return aptr[position]; } vector<T>::T &operator[](const int &){ return aptr[]; } vector<T>::T &back(){ T.back(arrayCapacity); } vector<T>::T &front(){ T.front(arrayCapacity); } vector<T>::arraySize(T){ if (arraySize == arrayCapacity) { arrayCapacity += arraySize; int *temp = new long[arrayCapacity]; for (long i = -1; i < arraySize; i++){ temp[i] = aptrPtr[i]; delete[] aptrPtr;
  • 7. aptr = temp; } aptrPtr[arraySize] = T; arraySize++; } vector<T>::T pop_back(){ return aptrPtr[--arraySize]; } vector<T>::insert(unsigned long, const T &){ T.insert (position,arrayCapacity); } vector<T>::erase(unsigned long, unsigned long){ T.erase (position,arrayCapacity); } vector<T>::erase(unsigned long){ T.erase (position); } } #endif - T*aptr. The pointer being used for the internal array maintained by the vector class. You may change this name if you want :) - T &at(int): access the element at the given index and throws an - unsigned long arraySize: The value that represents the current number exception if out of bounds of elements in the vector - T &operator[](const int &): access the element at the given index - unsigned long arrayCapacity: The value that represents the current and does not check bounds for efficiency purposes. allocated memory capacity of the vector (must always be >= arraySize) - T &back(): access the last element in the vector - T &front(): access the first element in the vector You will find the following private method: Modifying methods: - void increaseCapacity(unsigned long): This method is used for - void push_back(T): adds an element to the end of the vector increasing the capacity of the vector. It should not be public, but other methods in the class would need it. NOTE: You may add more private methods if you see opportunities for code reuse across the needs of the - T pop_back(): removes the last element of the vector and returns it public vector methods. - int insert(unsigned long, const T &): Inserts the element in the 2nd parameter at the position given by the 1st parameter - void erase(unsigned long, unsigned long): Removes the elements starting with the element at the position of the first parameter up to the You will find the following public methods: There are 3 constructors. element before the position in the 2nd parameter i.e. do not remove the - vector(): This constructor creates a vector with a capacity of 10 and size element at the position of the 2nd parameter. of 0 . - vector(unsigned long): This constructor creates a vector with the capacity given by the parameter and size will be 0 . - vector(const vector &): This is the copy constructor
  • 8. for the class There 2 resize methods: - void resize(unsigned long n ): Resize the vector based on this parameter. Resize can make it smaller or larger; if it's made smaller the capacity is unchanged (makes the vector more efficient). - void resize(unsigned long n , const T &): Resize the vector, and if it's made larger then fill in the new elements with value of the 2 nd parameter. The destructor: vector(): This needs to clean up all memory allocated to the vector Accessor methods: - unsigned long size() const: returns the size attribute of the vector - unsigned long capacity() const: returns the capacity attribute of the vector - bool empty() const returns true if the vector is empty, and false otherwise vector.h:141:9: error: template argument 1 is invalid