in c++ language, I already solved the problem and ran it fine. But I got a pile of warning, I wonder if it will affect my…

in c++ language, I already solved the problem and ran it fine. But I got a pile of warning, I wonder if it will affect my code to run. Here’s the problem from the exercise. (Implement a stack class using inheritance) In listing 12.4, GenericStack is implemented using arrays. Create a new stack class that extends vector. Implement it.

[UPDATED]: Just ignore all header files and problems. All I want you to do is on prog 15_5().

Don't use plagiarized sources. Get Your Custom Essay on
in c++ language, I already solved the problem and ran it fine. But I got a pile of warning, I wonder if it will affect my…
Get an essay WRITTEN FOR YOU, Plagiarism free, and by an EXPERT!
Order Essay

MyVector.h

#ifndef MYVECTOR
#define MYVECTOR
#include

template
class MyVector
{
public:
MyVector();
void push_back(T);
void pop_back();
unsigned int size();
bool isEmpty();
T at(int index);
T peek();
int clear();
void swap(MyVector v2);

private:
T elements[100];
int vectorSize;
};
#endif

MyVector.cpp

#include “MyVector.h”

template
// no-argument generic constructor definition
MyVector::MyVector()
{
vectorSize = 0;
}

template
bool MyVector::isEmpty()
{
return (vectorSize == 0);
}

template
T MyVector::at(int index)
{
return elements[index];
}

template
void MyVector::push_back(T value)
{
elements[vectorSize++] = value;
}

template
void MyVector::pop_back()
{
elements[–vectorSize];
}

template
T MyVector::peek()
{
return elements[0];
}

template
unsigned int MyVector:: size()
{
return vectorSize;
}

template
int MyVector::clear()
{
vectorSize = 0;
return vectorSize;
}

template
void MyVector::swap(MyVector v2)
{
T temp[100];
int tempSize=v2.size();

for(int i=0;i        temp[i]=v2.at(i);

this->clear();

for(int i=0;i        this->push_back(temp[i]);
/*T temp[100];
int tempSize = v2.size();

for (int i = 0; i < v2.size(); i++)
temp.push_back(at(i));
clear();

for (int i = 0; i        this->push_back(temp[i]);*/
}

main.cpp

#include <iostream>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include “Triangle.h”
#include “GeometricObject.h”
#include “MyVector.cpp”
#include “Person.h”
#include “MyDate.h”
#include “Faculty.h”
#include “Staff.h”
#include “Calendar.h”
#include “ImprovedMyPoint.h”
#include “ThreeDPoint.h”
#include “NewAccount.h”
#include “CheckingAcc.h”
#include “SavingAcc.h”
#include “MyVector.h”
using namespace std;

//to solve a problem #15_5
void Prog15_5()
{
MyVector v1;
MyVector v2;
cout << “**********************************Base Class************************” << endl;

//call the isempty() and return true if the vector is empty
if (v1.isEmpty())
cout << “nThe vector is empty” << endl;

cout << “nAdd the elements to base class ‘MyVector’v1” << endl;

//call the push_bacl()
v1.push_back(1);
v1.push_back(2);
v1.push_back(3);

for (int i = 0; i < v1.size(); i++)
{
cout << v1.at(i) << endl;
}

cout << “nSize of the elements in base class ‘MyVector’v1:” << v1.size() << endl;
cout << “nRemove of the last element in base class ‘MyVector’v1:” << endl;

v1.pop_back();
cout << “nSize of the elements in base class ‘MyVector’ after removed:” << v1.size() << endl;
cout << “nAdd the elements to the base class’MyVector’v2” << endl;
v2.push_back(4);
v2.push_back(5);
v2.push_back(6);
v2.push_back(7);

for (int i =0; i < v2.size(); i++)
cout << v2.at(i) << endl;

cout << “nSize of the elements in base class ‘MyVector’v2:” << v2.size() << endl;

cout << “nSwap the contents between v1 and v2” << endl;
v1.swap(v2);
cout << “nElements in the base class ‘MyVector’v1 after swapped” << endl;

for (int i = 0; i < v1.size(); i++)
cout << v1.at(i) << endl;

cout << “nClear the elements in the base class ‘MyVector’v1” << endl;
v1.clear();
cout << “nSize of the base class ‘MyVector’v1: ” << v1.size() << endl << endl;

cout << “**********************************Derivied Class************************” << endl;

if (v1.isEmpty());
cout <<“nThe stack is empty”;

cout <<“nAdd the elements to derivied class ‘Stack’ ” << endl;

//call the push()
v1.push_back(9);
v1.push_back(8);
v1.push_back(7);

cout << “nSize of the elements in derivded class ‘Stack’ ” << v1.size() << endl;
cout << “nThe top of the element from the derived class ‘Stack’ ” << v1.peek() << endl;
cout << “nRemove the last element from the derived class ‘Stack’ ” << endl;

v1.pop_back();
cout << “n Size of the elements in derived class ‘Stack’ after removed” << v1.size() << endl;
cout << “nThe top of the element from the derived class ‘Stack’ after removed” << v1.peek() << endl;
}

int main()
{
while (true)
{
system(“cls”);
cout << “nMain Menu – Chapter 15” << endl;
cout << “==============================” << endl;
cout << ” 1: Programming Exercise 15.1″ << endl;
cout << ” 2: Programming Exercise 15.2″ << endl;
cout << ” 3: Programming Exercise 15.3″ << endl;
cout << ” 4: Programming Exercise 15.4″ << endl;
cout << ” 5: Programming Exercise 15.5″ << endl;
cout << “other: Exit” << endl;
cout << “==============================” << endl;
cout << “Enter an exercise: “;
char exercise[2];
cin >> exercise;
cout << endl;
switch (atoi(exercise))
{
case 1: Prog15_1(); break;
case 2: Prog15_2(); break;
case 3: Prog15_3(); break;
case 4: Prog15_4(); break;
case 5: Prog15_5(); break;

default: exit(0);
}
cout << endl;
system(“pause”);
cin.clear();
}

return 0;
}

Expert Answer

 #include <iostream>

#include <vector>
#include “MyVector.h”
using namespace std;

template <class T>
MyVector::MyVector()
{
vectorSize = 0;
}

template <class T>
bool MyVector::isEmpty()
{
return data.empty();
}
template <class T>
T MyVector::at(int index)
{
return data.at(index);
}
template <class T>
void MyVector::push_back(T value)
{
data.push_back(value);
}
template <class T>
void MyVector::pop_back()
{
data.pop_back();
}
template <class T>
T MyVector::peek()
{
return data.at(data.size()-1);
}
template <class T>
unsigned int MyVector:: size()
{
return vectorSize;
}
template <class T>
int MyVector::clear()
{
vectorSize = 0;
data.clear();
return vectorSize;
}

Top Grade Homework
Order NOW For a 10% Discount!
Pages (550 words)
Approximate price: -

Why Work with Us

Top Quality and Well-Researched Papers

We always make sure that writers follow all your instructions precisely. You can choose your academic level: high school, college/university or professional, and we will assign a writer who has a respective degree.

Professional and Experienced Academic Writers

We have a team of professional writers with experience in academic and business writing. Many are native speakers and able to perform any task for which you need help.

Free Unlimited Revisions

If you think we missed something, send your order for a free revision. You have 10 days to submit the order for review after you have received the final document. You can do this yourself after logging into your personal account or by contacting our support.

Prompt Delivery and 100% Money-Back-Guarantee

All papers are always delivered on time. In case we need more time to master your paper, we may contact you regarding the deadline extension. In case you cannot provide us with more time, a 100% refund is guaranteed.

Original & Confidential

We use several writing tools checks to ensure that all documents you receive are free from plagiarism. Our editors carefully review all quotations in the text. We also promise maximum confidentiality in all of our services.

24/7 Customer Support

Our support agents are available 24 hours a day 7 days a week and committed to providing you with the best customer experience. Get in touch whenever you need any assistance.

Try it now!

Calculate the price of your order

Total price:
$0.00

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

Our Services

No need to work on your paper at night. Sleep tight, we will cover your back. We offer all kinds of writing services.

Essays

Essay Writing Service

No matter what kind of academic paper you need and how urgent you need it, you are welcome to choose your academic level and the type of your paper at an affordable price. We take care of all your paper needs and give a 24/7 customer care support system.

Admissions

Admission Essays & Business Writing Help

An admission essay is an essay or other written statement by a candidate, often a potential student enrolling in a college, university, or graduate school. You can be rest assurred that through our service we will write the best admission essay for you.

Reviews

Editing Support

Our academic writers and editors make the necessary changes to your paper so that it is polished. We also format your document by correctly quoting the sources and creating reference lists in the formats APA, Harvard, MLA, Chicago / Turabian.

Reviews

Revision Support

If you think your paper could be improved, you can request a review. In this case, your paper will be checked by the writer or assigned to an editor. You can use this option as many times as you see fit. This is free because we want you to be completely satisfied with the service offered.

× Contact Live Agents