SlideShare a Scribd company logo
1 of 4
Download to read offline
Files that you must write and turn in (Please do not turn in other files!!):
sequence2.h: The header file for the new sequence class. Actually, you don't have to write much
of this file. If some of your member functions are implemented as inline functions, then you may
put those implementations in this file too. By the way, you might want to compare this header file
with your first sequence header file sequence1.h, the new version no longer has a CAPACITY
constant because the items are stored in a dynamic array that grows as needed. But there is a
DEFAULT_CAPACITY constant, which provides the initial size of the array for a sequence created
by the default constructor.
sequence2.cpp: The implementation file for the new sequence class. You will write all of this file,
which will have the implementations of all the sequence's member functions
sequence2.h
#ifndef MAIN_SAVITCH_SEQUENCE_H
#define MAIN_SAVITCH_SEQUENCE_H
#include <cstdlib> // Provides size_t
namespace main_savitch_4
{
class sequence
{
public:
// TYPEDEFS and MEMBER CONSTANTS
typedef double value_type;
typedef std::size_t size_type;
static const size_type DEFAULT_CAPACITY = 30;
// CONSTRUCTORS and DESTRUCTOR
sequence(size_type initial_capacity = DEFAULT_CAPACITY);
sequence(const sequence& source);
~sequence( );
// MODIFICATION MEMBER FUNCTIONS
void resize(size_type new_capacity);
void start( );
void advance( );
void insert(const value_type& entry);
void attach(const value_type& entry);
void remove_current( );
void operator =(const sequence& source);
// CONSTANT MEMBER FUNCTIONS
size_type size( ) const;
bool is_item( ) const;
value_type current( ) const;
void operator +=(const sequence& source);
void operator +(const sequence& source);
value_type operator[](size_type index) const;
private:
value_type* data;
size_type used;
size_type current_index;
size_type capacity;
};
}
#endif
sequence2.cpp
#include "sequence2.h"
#include <algorithm>
#include <cassert>
namespace main_savitch_4 {
// CONSTRUCTORS AND DESTRUCTOR
sequence::sequence(size_type initial_capacity) {
data = new value_type[initial_capacity];
capacity = initial_capacity;
used = 0;
current_index = 0;
}
sequence::sequence(const sequence& source) {
data = new value_type[source.capacity];
capacity = source.capacity;
used = source.used;
current_index = source.current_index;
std::copy(source.data, source.data + used, data);
}
sequence::~sequence() {
delete[] data;
}
// MODIFICATION MEMBER FUNCTIONS
void sequence::resize(size_type new_capacity) {
if (new_capacity == capacity)
return;
if (new_capacity < used)
new_capacity = used;
value_type* new_data = new value_type[new_capacity];
std::copy(data, data + used, new_data);
delete[] data;
data = new_data;
capacity = new_capacity;
}
void sequence::start() {
if (used > 0)
current_index = 0;
}
void sequence::advance() {
if (is_item())
++current_index;
}
void sequence::insert(const value_type& entry) {
if (size() == capacity)
resize(capacity * 2);
if (!is_item()) // No current item, so insert at start
current_index = 0;
for (size_type i = used; i > current_index; --i)
data[i] = data[i - 1];
data[current_index] = entry;
++used;
}
void sequence::attach(const value_type& entry) {
if (size() == capacity)
resize(capacity * 2);
if (!is_item()) // No current item, so attach at end
current_index = used - 1;
++current_index;
for (size_type i = used; i > current_index; --i)
data[i] = data[i - 1];
data[current_index] = entry;
++used;
}
void sequence::remove_current() {
assert(is_item());
for (size_type i = current_index; i < used - 1; ++i)
data[i] = data[i + 1];
--used;
}
void sequence::operator=(const sequence& source) {
if (this == &source)
return;
value_type* new_data = new value_type[source.capacity];
std::copy(source.data, source.data + source.used, new_data);
delete[] data;
data = new_data;
capacity = source.capacity;
used = source.used;
current_index = source.current_index;
}
void sequence::operator+=(const sequence& source) {
if (size() + source.size() > capacity)
resize(size() + source.size());
std::copy(source.data, source.data + source.used, data + used);
used += source.used;
}
sequence sequence::operator+(const sequence& source) const {
sequence result(size() + source.size());
std::copy(data, data + used, result.data);
std::copy(source.data, source.data + source.used, result.data + used);
result.used = used + source.used;
return result;
}
sequence::value_type sequence::operator[](size_type index) const {
assert(index < used);
}
}
Error:
./sequence2.cpp:111:24: error: out-of-line definition of 'operator+' does not match any declaration
in 'main_savitch_4::sequence'
sequence sequence::operator+(const sequence& source) const {
^~~~~~~~
./sequence2.h:128:8: note: member declaration does not match because it is not const qualified
void operator +(const sequence& source);
^ ~
1 error generated.
make: *** [Makefile:10: main] Error 1

More Related Content

Similar to Files that you must write and turn in Please do not turn in.pdf

In Class AssignmetzCST280W13a-1.pdfCST 280 In-Class Pract.docx
In Class AssignmetzCST280W13a-1.pdfCST 280 In-Class Pract.docxIn Class AssignmetzCST280W13a-1.pdfCST 280 In-Class Pract.docx
In Class AssignmetzCST280W13a-1.pdfCST 280 In-Class Pract.docxbradburgess22840
 
Write a Java Class to Implement a Generic Linked ListYour list mus.pdf
Write a Java Class to Implement a Generic Linked ListYour list mus.pdfWrite a Java Class to Implement a Generic Linked ListYour list mus.pdf
Write a Java Class to Implement a Generic Linked ListYour list mus.pdfrozakashif85
 
Data Processing Using Quantum
Data Processing Using QuantumData Processing Using Quantum
Data Processing Using Quantumnibraspk
 
Queue Data Structure
Queue Data StructureQueue Data Structure
Queue Data StructureSriram Raj
 
Queue Data Structure
Queue Data StructureQueue Data Structure
Queue Data StructureZidny Nafan
 
IO redirection in C shellPlease implement input output redirect.pdf
IO redirection in C shellPlease implement input  output redirect.pdfIO redirection in C shellPlease implement input  output redirect.pdf
IO redirection in C shellPlease implement input output redirect.pdfforecastfashions
 
File name a2.cppTaskFor this assignment, you are required to ei.pdf
File name a2.cppTaskFor this assignment, you are required to ei.pdfFile name a2.cppTaskFor this assignment, you are required to ei.pdf
File name a2.cppTaskFor this assignment, you are required to ei.pdfinfomalad
 
in c languageTo determine the maximum string length, we need to .pdf
in c languageTo determine the maximum string length, we need to .pdfin c languageTo determine the maximum string length, we need to .pdf
in c languageTo determine the maximum string length, we need to .pdfstopgolook
 
need help with my computer science lab assignemnt. this assignment i.pdf
need help with my computer science lab assignemnt. this assignment i.pdfneed help with my computer science lab assignemnt. this assignment i.pdf
need help with my computer science lab assignemnt. this assignment i.pdffathimaoptical
 
#include iostream #include cstring #include vector #i.pdf
 #include iostream #include cstring #include vector #i.pdf #include iostream #include cstring #include vector #i.pdf
#include iostream #include cstring #include vector #i.pdfanandatalapatra
 
all i need is these two filesCreate VectorContainer.hppCreat.docx
all i need is these two filesCreate VectorContainer.hppCreat.docxall i need is these two filesCreate VectorContainer.hppCreat.docx
all i need is these two filesCreate VectorContainer.hppCreat.docxjack60216
 
MySQL shell and It's utilities - Praveen GR (Mydbops Team)
MySQL shell and It's utilities - Praveen GR (Mydbops Team)MySQL shell and It's utilities - Praveen GR (Mydbops Team)
MySQL shell and It's utilities - Praveen GR (Mydbops Team)Mydbops
 
For problems 3 and 4, consider the following functions that implemen.pdf
For problems 3 and 4, consider the following functions that implemen.pdfFor problems 3 and 4, consider the following functions that implemen.pdf
For problems 3 and 4, consider the following functions that implemen.pdfanjandavid
 
Spring data ii
Spring data iiSpring data ii
Spring data ii명철 강
 
Using Array Approach, Linked List approach, and Delete Byte Approach.pdf
Using Array Approach, Linked List approach, and Delete Byte Approach.pdfUsing Array Approach, Linked List approach, and Delete Byte Approach.pdf
Using Array Approach, Linked List approach, and Delete Byte Approach.pdffms12345
 
BackgroundIn many applications, the composition of a collection o.pdf
BackgroundIn many applications, the composition of a collection o.pdfBackgroundIn many applications, the composition of a collection o.pdf
BackgroundIn many applications, the composition of a collection o.pdfmayorothenguyenhob69
 

Similar to Files that you must write and turn in Please do not turn in.pdf (20)

In Class AssignmetzCST280W13a-1.pdfCST 280 In-Class Pract.docx
In Class AssignmetzCST280W13a-1.pdfCST 280 In-Class Pract.docxIn Class AssignmetzCST280W13a-1.pdfCST 280 In-Class Pract.docx
In Class AssignmetzCST280W13a-1.pdfCST 280 In-Class Pract.docx
 
CPP Assignment Help
CPP Assignment HelpCPP Assignment Help
CPP Assignment Help
 
Write a Java Class to Implement a Generic Linked ListYour list mus.pdf
Write a Java Class to Implement a Generic Linked ListYour list mus.pdfWrite a Java Class to Implement a Generic Linked ListYour list mus.pdf
Write a Java Class to Implement a Generic Linked ListYour list mus.pdf
 
Data Processing Using Quantum
Data Processing Using QuantumData Processing Using Quantum
Data Processing Using Quantum
 
Queue Data Structure
Queue Data StructureQueue Data Structure
Queue Data Structure
 
Queue Data Structure
Queue Data StructureQueue Data Structure
Queue Data Structure
 
IO redirection in C shellPlease implement input output redirect.pdf
IO redirection in C shellPlease implement input  output redirect.pdfIO redirection in C shellPlease implement input  output redirect.pdf
IO redirection in C shellPlease implement input output redirect.pdf
 
File name a2.cppTaskFor this assignment, you are required to ei.pdf
File name a2.cppTaskFor this assignment, you are required to ei.pdfFile name a2.cppTaskFor this assignment, you are required to ei.pdf
File name a2.cppTaskFor this assignment, you are required to ei.pdf
 
in c languageTo determine the maximum string length, we need to .pdf
in c languageTo determine the maximum string length, we need to .pdfin c languageTo determine the maximum string length, we need to .pdf
in c languageTo determine the maximum string length, we need to .pdf
 
Programming Assignment Help
Programming Assignment HelpProgramming Assignment Help
Programming Assignment Help
 
need help with my computer science lab assignemnt. this assignment i.pdf
need help with my computer science lab assignemnt. this assignment i.pdfneed help with my computer science lab assignemnt. this assignment i.pdf
need help with my computer science lab assignemnt. this assignment i.pdf
 
#include iostream #include cstring #include vector #i.pdf
 #include iostream #include cstring #include vector #i.pdf #include iostream #include cstring #include vector #i.pdf
#include iostream #include cstring #include vector #i.pdf
 
all i need is these two filesCreate VectorContainer.hppCreat.docx
all i need is these two filesCreate VectorContainer.hppCreat.docxall i need is these two filesCreate VectorContainer.hppCreat.docx
all i need is these two filesCreate VectorContainer.hppCreat.docx
 
MySQL shell and It's utilities - Praveen GR (Mydbops Team)
MySQL shell and It's utilities - Praveen GR (Mydbops Team)MySQL shell and It's utilities - Praveen GR (Mydbops Team)
MySQL shell and It's utilities - Praveen GR (Mydbops Team)
 
Memory Management In C++
Memory Management In C++Memory Management In C++
Memory Management In C++
 
For problems 3 and 4, consider the following functions that implemen.pdf
For problems 3 and 4, consider the following functions that implemen.pdfFor problems 3 and 4, consider the following functions that implemen.pdf
For problems 3 and 4, consider the following functions that implemen.pdf
 
Spring data ii
Spring data iiSpring data ii
Spring data ii
 
Angular Schematics
Angular SchematicsAngular Schematics
Angular Schematics
 
Using Array Approach, Linked List approach, and Delete Byte Approach.pdf
Using Array Approach, Linked List approach, and Delete Byte Approach.pdfUsing Array Approach, Linked List approach, and Delete Byte Approach.pdf
Using Array Approach, Linked List approach, and Delete Byte Approach.pdf
 
BackgroundIn many applications, the composition of a collection o.pdf
BackgroundIn many applications, the composition of a collection o.pdfBackgroundIn many applications, the composition of a collection o.pdf
BackgroundIn many applications, the composition of a collection o.pdf
 

More from actocomputer

Figure 3 below shows that the survival rate of Blue Wildeb.pdf
Figure 3 below shows that the survival rate of Blue Wildeb.pdfFigure 3 below shows that the survival rate of Blue Wildeb.pdf
Figure 3 below shows that the survival rate of Blue Wildeb.pdfactocomputer
 
FIGURE 241 Refer to Figure 241 Suppose the economy is cur.pdf
FIGURE 241 Refer to Figure 241 Suppose the economy is cur.pdfFIGURE 241 Refer to Figure 241 Suppose the economy is cur.pdf
FIGURE 241 Refer to Figure 241 Suppose the economy is cur.pdfactocomputer
 
Fibroblast cells from patients Jack Karen Agatha and Tony.pdf
Fibroblast cells from patients Jack Karen Agatha and Tony.pdfFibroblast cells from patients Jack Karen Agatha and Tony.pdf
Fibroblast cells from patients Jack Karen Agatha and Tony.pdfactocomputer
 
Fetal pig What is the purpose of the pericardial sac that su.pdf
Fetal pig What is the purpose of the pericardial sac that su.pdfFetal pig What is the purpose of the pericardial sac that su.pdf
Fetal pig What is the purpose of the pericardial sac that su.pdfactocomputer
 
Find the probability PEc if PE019 The probability PE.pdf
Find the probability PEc if PE019 The probability PE.pdfFind the probability PEc if PE019 The probability PE.pdf
Find the probability PEc if PE019 The probability PE.pdfactocomputer
 
Feral pigs are an invasive species around the world They ca.pdf
Feral pigs are an invasive species around the world They ca.pdfFeral pigs are an invasive species around the world They ca.pdf
Feral pigs are an invasive species around the world They ca.pdfactocomputer
 
Find the maximum likelihood estimator of +2 Suppose that .pdf
Find the maximum likelihood estimator of +2 Suppose that .pdfFind the maximum likelihood estimator of +2 Suppose that .pdf
Find the maximum likelihood estimator of +2 Suppose that .pdfactocomputer
 
Find the indicated IQ score The graph to the right depicts .pdf
Find the indicated IQ score The graph to the right depicts .pdfFind the indicated IQ score The graph to the right depicts .pdf
Find the indicated IQ score The graph to the right depicts .pdfactocomputer
 
Female labour force participation rate and economic growth i.pdf
Female labour force participation rate and economic growth i.pdfFemale labour force participation rate and economic growth i.pdf
Female labour force participation rate and economic growth i.pdfactocomputer
 
FedEx construy su negocio sobre la base de la entrega rpid.pdf
FedEx construy su negocio sobre la base de la entrega rpid.pdfFedEx construy su negocio sobre la base de la entrega rpid.pdf
FedEx construy su negocio sobre la base de la entrega rpid.pdfactocomputer
 
fecower Kayimood Dwicyo Soens sherwood Compact dise playe.pdf
fecower Kayimood Dwicyo Soens sherwood Compact dise playe.pdffecower Kayimood Dwicyo Soens sherwood Compact dise playe.pdf
fecower Kayimood Dwicyo Soens sherwood Compact dise playe.pdfactocomputer
 
Find the area of the shaded region The graph to the right de.pdf
Find the area of the shaded region The graph to the right de.pdfFind the area of the shaded region The graph to the right de.pdf
Find the area of the shaded region The graph to the right de.pdfactocomputer
 
Find code that you wrote and apply 2 of the 3 design princip.pdf
Find code that you wrote and apply 2 of the 3 design princip.pdfFind code that you wrote and apply 2 of the 3 design princip.pdf
Find code that you wrote and apply 2 of the 3 design princip.pdfactocomputer
 
Find a current news article or video within the past 12 mon.pdf
Find a current news article or video within the past 12 mon.pdfFind a current news article or video within the past 12 mon.pdf
Find a current news article or video within the past 12 mon.pdfactocomputer
 
Female pig Emmy Lou straight tail whitehaired with the h.pdf
Female pig Emmy Lou straight tail whitehaired with the h.pdfFemale pig Emmy Lou straight tail whitehaired with the h.pdf
Female pig Emmy Lou straight tail whitehaired with the h.pdfactocomputer
 
Financing Assumptions Please assume a traditional bank cons.pdf
Financing Assumptions Please assume a traditional bank cons.pdfFinancing Assumptions Please assume a traditional bank cons.pdf
Financing Assumptions Please assume a traditional bank cons.pdfactocomputer
 
FigURE 01 Needle intersecting the border of the ruled tabl.pdf
FigURE 01 Needle intersecting the border of the ruled tabl.pdfFigURE 01 Needle intersecting the border of the ruled tabl.pdf
FigURE 01 Needle intersecting the border of the ruled tabl.pdfactocomputer
 
Financial InformationFinancial InformationFinancial In.pdf
Financial InformationFinancial InformationFinancial In.pdfFinancial InformationFinancial InformationFinancial In.pdf
Financial InformationFinancial InformationFinancial In.pdfactocomputer
 
Fewer open fNa+ and Ca++ channels during the pacemaker poten.pdf
Fewer open fNa+ and Ca++ channels during the pacemaker poten.pdfFewer open fNa+ and Ca++ channels during the pacemaker poten.pdf
Fewer open fNa+ and Ca++ channels during the pacemaker poten.pdfactocomputer
 
FIN 3100 Principios de Finanzas Caso de estudio Barry y S.pdf
FIN 3100 Principios de Finanzas   Caso de estudio  Barry y S.pdfFIN 3100 Principios de Finanzas   Caso de estudio  Barry y S.pdf
FIN 3100 Principios de Finanzas Caso de estudio Barry y S.pdfactocomputer
 

More from actocomputer (20)

Figure 3 below shows that the survival rate of Blue Wildeb.pdf
Figure 3 below shows that the survival rate of Blue Wildeb.pdfFigure 3 below shows that the survival rate of Blue Wildeb.pdf
Figure 3 below shows that the survival rate of Blue Wildeb.pdf
 
FIGURE 241 Refer to Figure 241 Suppose the economy is cur.pdf
FIGURE 241 Refer to Figure 241 Suppose the economy is cur.pdfFIGURE 241 Refer to Figure 241 Suppose the economy is cur.pdf
FIGURE 241 Refer to Figure 241 Suppose the economy is cur.pdf
 
Fibroblast cells from patients Jack Karen Agatha and Tony.pdf
Fibroblast cells from patients Jack Karen Agatha and Tony.pdfFibroblast cells from patients Jack Karen Agatha and Tony.pdf
Fibroblast cells from patients Jack Karen Agatha and Tony.pdf
 
Fetal pig What is the purpose of the pericardial sac that su.pdf
Fetal pig What is the purpose of the pericardial sac that su.pdfFetal pig What is the purpose of the pericardial sac that su.pdf
Fetal pig What is the purpose of the pericardial sac that su.pdf
 
Find the probability PEc if PE019 The probability PE.pdf
Find the probability PEc if PE019 The probability PE.pdfFind the probability PEc if PE019 The probability PE.pdf
Find the probability PEc if PE019 The probability PE.pdf
 
Feral pigs are an invasive species around the world They ca.pdf
Feral pigs are an invasive species around the world They ca.pdfFeral pigs are an invasive species around the world They ca.pdf
Feral pigs are an invasive species around the world They ca.pdf
 
Find the maximum likelihood estimator of +2 Suppose that .pdf
Find the maximum likelihood estimator of +2 Suppose that .pdfFind the maximum likelihood estimator of +2 Suppose that .pdf
Find the maximum likelihood estimator of +2 Suppose that .pdf
 
Find the indicated IQ score The graph to the right depicts .pdf
Find the indicated IQ score The graph to the right depicts .pdfFind the indicated IQ score The graph to the right depicts .pdf
Find the indicated IQ score The graph to the right depicts .pdf
 
Female labour force participation rate and economic growth i.pdf
Female labour force participation rate and economic growth i.pdfFemale labour force participation rate and economic growth i.pdf
Female labour force participation rate and economic growth i.pdf
 
FedEx construy su negocio sobre la base de la entrega rpid.pdf
FedEx construy su negocio sobre la base de la entrega rpid.pdfFedEx construy su negocio sobre la base de la entrega rpid.pdf
FedEx construy su negocio sobre la base de la entrega rpid.pdf
 
fecower Kayimood Dwicyo Soens sherwood Compact dise playe.pdf
fecower Kayimood Dwicyo Soens sherwood Compact dise playe.pdffecower Kayimood Dwicyo Soens sherwood Compact dise playe.pdf
fecower Kayimood Dwicyo Soens sherwood Compact dise playe.pdf
 
Find the area of the shaded region The graph to the right de.pdf
Find the area of the shaded region The graph to the right de.pdfFind the area of the shaded region The graph to the right de.pdf
Find the area of the shaded region The graph to the right de.pdf
 
Find code that you wrote and apply 2 of the 3 design princip.pdf
Find code that you wrote and apply 2 of the 3 design princip.pdfFind code that you wrote and apply 2 of the 3 design princip.pdf
Find code that you wrote and apply 2 of the 3 design princip.pdf
 
Find a current news article or video within the past 12 mon.pdf
Find a current news article or video within the past 12 mon.pdfFind a current news article or video within the past 12 mon.pdf
Find a current news article or video within the past 12 mon.pdf
 
Female pig Emmy Lou straight tail whitehaired with the h.pdf
Female pig Emmy Lou straight tail whitehaired with the h.pdfFemale pig Emmy Lou straight tail whitehaired with the h.pdf
Female pig Emmy Lou straight tail whitehaired with the h.pdf
 
Financing Assumptions Please assume a traditional bank cons.pdf
Financing Assumptions Please assume a traditional bank cons.pdfFinancing Assumptions Please assume a traditional bank cons.pdf
Financing Assumptions Please assume a traditional bank cons.pdf
 
FigURE 01 Needle intersecting the border of the ruled tabl.pdf
FigURE 01 Needle intersecting the border of the ruled tabl.pdfFigURE 01 Needle intersecting the border of the ruled tabl.pdf
FigURE 01 Needle intersecting the border of the ruled tabl.pdf
 
Financial InformationFinancial InformationFinancial In.pdf
Financial InformationFinancial InformationFinancial In.pdfFinancial InformationFinancial InformationFinancial In.pdf
Financial InformationFinancial InformationFinancial In.pdf
 
Fewer open fNa+ and Ca++ channels during the pacemaker poten.pdf
Fewer open fNa+ and Ca++ channels during the pacemaker poten.pdfFewer open fNa+ and Ca++ channels during the pacemaker poten.pdf
Fewer open fNa+ and Ca++ channels during the pacemaker poten.pdf
 
FIN 3100 Principios de Finanzas Caso de estudio Barry y S.pdf
FIN 3100 Principios de Finanzas   Caso de estudio  Barry y S.pdfFIN 3100 Principios de Finanzas   Caso de estudio  Barry y S.pdf
FIN 3100 Principios de Finanzas Caso de estudio Barry y S.pdf
 

Recently uploaded

OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsSandeep D Chaudhary
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...EduSkills OECD
 
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxAnalyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxLimon Prince
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code ExamplesPeter Brusilovsky
 
ANTI PARKISON DRUGS.pptx
ANTI         PARKISON          DRUGS.pptxANTI         PARKISON          DRUGS.pptx
ANTI PARKISON DRUGS.pptxPoojaSen20
 
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportBasic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportDenish Jangid
 
How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17Celine George
 
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhĐề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhleson0603
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...Nguyen Thanh Tu Collection
 
Book Review of Run For Your Life Powerpoint
Book Review of Run For Your Life PowerpointBook Review of Run For Your Life Powerpoint
Book Review of Run For Your Life Powerpoint23600690
 
Major project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesMajor project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesAmanpreetKaur157993
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjMohammed Sikander
 
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaPersonalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaEADTU
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17Celine George
 
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...Nguyen Thanh Tu Collection
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文中 央社
 
Trauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesTrauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesPooky Knightsmith
 

Recently uploaded (20)

Including Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdfIncluding Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdf
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...
 
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxAnalyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
 
ANTI PARKISON DRUGS.pptx
ANTI         PARKISON          DRUGS.pptxANTI         PARKISON          DRUGS.pptx
ANTI PARKISON DRUGS.pptx
 
Supporting Newcomer Multilingual Learners
Supporting Newcomer  Multilingual LearnersSupporting Newcomer  Multilingual Learners
Supporting Newcomer Multilingual Learners
 
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportBasic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
 
How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhĐề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
Book Review of Run For Your Life Powerpoint
Book Review of Run For Your Life PowerpointBook Review of Run For Your Life Powerpoint
Book Review of Run For Your Life Powerpoint
 
Major project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesMajor project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategies
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
 
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaPersonalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17
 
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
 
Trauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesTrauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical Principles
 

Files that you must write and turn in Please do not turn in.pdf

  • 1. Files that you must write and turn in (Please do not turn in other files!!): sequence2.h: The header file for the new sequence class. Actually, you don't have to write much of this file. If some of your member functions are implemented as inline functions, then you may put those implementations in this file too. By the way, you might want to compare this header file with your first sequence header file sequence1.h, the new version no longer has a CAPACITY constant because the items are stored in a dynamic array that grows as needed. But there is a DEFAULT_CAPACITY constant, which provides the initial size of the array for a sequence created by the default constructor. sequence2.cpp: The implementation file for the new sequence class. You will write all of this file, which will have the implementations of all the sequence's member functions sequence2.h #ifndef MAIN_SAVITCH_SEQUENCE_H #define MAIN_SAVITCH_SEQUENCE_H #include <cstdlib> // Provides size_t namespace main_savitch_4 { class sequence { public: // TYPEDEFS and MEMBER CONSTANTS typedef double value_type; typedef std::size_t size_type; static const size_type DEFAULT_CAPACITY = 30; // CONSTRUCTORS and DESTRUCTOR sequence(size_type initial_capacity = DEFAULT_CAPACITY); sequence(const sequence& source); ~sequence( ); // MODIFICATION MEMBER FUNCTIONS void resize(size_type new_capacity); void start( ); void advance( ); void insert(const value_type& entry); void attach(const value_type& entry); void remove_current( ); void operator =(const sequence& source); // CONSTANT MEMBER FUNCTIONS size_type size( ) const; bool is_item( ) const; value_type current( ) const; void operator +=(const sequence& source); void operator +(const sequence& source); value_type operator[](size_type index) const;
  • 2. private: value_type* data; size_type used; size_type current_index; size_type capacity; }; } #endif sequence2.cpp #include "sequence2.h" #include <algorithm> #include <cassert> namespace main_savitch_4 { // CONSTRUCTORS AND DESTRUCTOR sequence::sequence(size_type initial_capacity) { data = new value_type[initial_capacity]; capacity = initial_capacity; used = 0; current_index = 0; } sequence::sequence(const sequence& source) { data = new value_type[source.capacity]; capacity = source.capacity; used = source.used; current_index = source.current_index; std::copy(source.data, source.data + used, data); } sequence::~sequence() { delete[] data; } // MODIFICATION MEMBER FUNCTIONS void sequence::resize(size_type new_capacity) { if (new_capacity == capacity) return; if (new_capacity < used) new_capacity = used; value_type* new_data = new value_type[new_capacity]; std::copy(data, data + used, new_data); delete[] data; data = new_data; capacity = new_capacity; }
  • 3. void sequence::start() { if (used > 0) current_index = 0; } void sequence::advance() { if (is_item()) ++current_index; } void sequence::insert(const value_type& entry) { if (size() == capacity) resize(capacity * 2); if (!is_item()) // No current item, so insert at start current_index = 0; for (size_type i = used; i > current_index; --i) data[i] = data[i - 1]; data[current_index] = entry; ++used; } void sequence::attach(const value_type& entry) { if (size() == capacity) resize(capacity * 2); if (!is_item()) // No current item, so attach at end current_index = used - 1; ++current_index; for (size_type i = used; i > current_index; --i) data[i] = data[i - 1]; data[current_index] = entry; ++used; } void sequence::remove_current() { assert(is_item()); for (size_type i = current_index; i < used - 1; ++i) data[i] = data[i + 1]; --used; } void sequence::operator=(const sequence& source) { if (this == &source) return; value_type* new_data = new value_type[source.capacity]; std::copy(source.data, source.data + source.used, new_data); delete[] data; data = new_data;
  • 4. capacity = source.capacity; used = source.used; current_index = source.current_index; } void sequence::operator+=(const sequence& source) { if (size() + source.size() > capacity) resize(size() + source.size()); std::copy(source.data, source.data + source.used, data + used); used += source.used; } sequence sequence::operator+(const sequence& source) const { sequence result(size() + source.size()); std::copy(data, data + used, result.data); std::copy(source.data, source.data + source.used, result.data + used); result.used = used + source.used; return result; } sequence::value_type sequence::operator[](size_type index) const { assert(index < used); } } Error: ./sequence2.cpp:111:24: error: out-of-line definition of 'operator+' does not match any declaration in 'main_savitch_4::sequence' sequence sequence::operator+(const sequence& source) const { ^~~~~~~~ ./sequence2.h:128:8: note: member declaration does not match because it is not const qualified void operator +(const sequence& source); ^ ~ 1 error generated. make: *** [Makefile:10: main] Error 1