Answered step by step
Verified Expert Solution
Question
1 Approved Answer
/ / Student ID: 2 0 5 3 7 0 1 6 / / TODO - Replace the number above with your actual student ID
Student ID:
TODO Replace the number above with your actual student ID
#ifndef Stacksh
#define Stacksh
#include
#include
class StackInt
private:
std::vector data;
public:
No explicit constructor or destructor
sizet size const
return data.size ;
bool isempty const
return data.size;
void pushint val
data.pushback val;
int topbool& success const
if isempty
success false;
return ;
else
success true;
return data.back;
bool pop
if isempty return false;
data.popback;
return true;
bool popint& val
if isempty
val ;
return false;
val data.back;
data.popback;
return true;
std::string tostring const
std::stringstream ss;
ss "Stack size elements: std::endl;
sizet count std::minsize staticcast;
for sizet i ; i count; i
ss datasize i std::endl;
if size
ss std::endl;
ss "Elements, if listed above, are in increasing order of age." std::endl;
return ssstr;
Don't remove the following line
friend class Tests;
;
class StackString
private:
std::vector data;
public:
No explicit constructor or destructor
sizet size const
return data.size ;
bool isempty const
return data.size;
void pushstd::string val
data.pushback val;
std::string topbool& success const
if isempty
success false;
return ;
else
success true;
return data.back;
bool pop
if isempty return false;
data.popback;
return true;
bool popstd::string& val
if isempty
val ;
return false;
val data.back;
data.popback;
return true;
std::string tostring const
std::stringstream ss;
ss "Stack size elements: std::endl;
sizet count std::minsize staticcast;
for sizet i ; i count; i
ss datai std::endl;
if size
ss std::endl;
ss "Elements, if listed above, are in increasing order of age." std::endl;
return ssstr;
Don't remove the following line
friend class Tests;
;
#endif Stacksh Checkpoint failed. Your tostring said:
Stack elements:
Elements, if listed above, are in increasing order of age.
But mine said:
Stack elements:
Elements, if listed above, are in increasing order of age.
Here is your stack:
Stack elements:
Elements, if listed above, are in increasing order of age.
And here is mine:
Stack elements:
Elements, if listed above, are in increasing order of age.
You think that's it in this i want lines of code but i dont know why it is giving me lines in output i need please help me
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started