Use c++. Thanks 5. Write a stack class using two STL lists. Naturally, a single
ID: 3592154 • Letter: U
Question
Use c++. Thanks
5. Write a stack class using two STL lists. Naturally, a single STL list is more than enough to represent a stack. However, you are only limited to the following STL list methods (a) void push back(const Object & x); //adds x to the end of list (b) void pop front); //removes the object at the front of the list (c) Object & front); //returns the object at the front of the list (d) bool empty() const; //true if empty container Limited to these methods alone, our STL list essentially becomes a queue (enqueue is basically push back while dequeue is a combination of front and pop_front). At the minimum, your stack class needs to have the followinjg (a) An STL list is stored as an instance member of the stack class. You can think of this main list as storing your stack. (b) A pop method that returns an Object at the top of the stack. (c) A push method that takes an Object and places it at the top of the stack (d) If your list is empty, your pop method should throw an exception (any exception will do) (e) Inside your push method, you can create a temporary list. As you are only limited to placing items at the back of your list (enqueue / push back), you can use this temporary list as storage to help move items from your main list to this list, add the new item to your main list, and then move back the items from the temporary list back to your main list.Explanation / Answer
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataKeyNames="EmployeeID" DataSourceID="SqlDataSource1"
Font-Names="Verdana"
Font-Size="14px" Width="289px">
<Columns>
<asp:BoundField DataField="LastName" HeaderText="LastName"
SortExpression="LastName" />
<asp:BoundField DataField="FirstName" HeaderText="FirstName"
SortExpression="FirstName" />
<asp:TemplateField HeaderText="Useless Group">
<ItemTemplate>
<asp:RadioButton ID="MyRadioButton" runat="server"
GroupName="UselessGroup" />
</ItemTemplate>
</asp:TemplateField>
C++
//Song Class
#ifndef SONG_CLASS
#define SONG_CLASS
using namespace std;
class Song
{
private:
string title; //dynamic allocation
string album;
string genre;
string artist;
double durationn;
public:
Song();
void setTitle(string t);
void setDuration(double d);
void setAlbumName(string a);
void setGenre(string g);
void setArtist(string a);
string getTitle();
string getAlbum()const;
string getGenre()const;
string getArtist()const;
double getDuration)(); //accessor
};
//constructor
Song::Song() //constructor
{
title="";
album="";
genre="";
artist="";
duration=0;
}
//accessor for name
string Song::getTitle()
{
return title;
}
//mutator
void Song::setTitle(string t)
{
title=t;
}
//accessor for name
string Song::getAlbum()
{
return album;
}
//mutator
void Song::setAlbumName(string a)
{
album=a;
}
//accessor for name
string Song::getGenre()
{
return genre;
}
//mutator
void Song::setGenre(string g)
{
genre=g;
}
//accessor for name
string Song::getArtist()
{
return artist;
}
//mutator
void Song::setArtist(string s)
{
artist=s;
}
void Song::setDuration(double d)
{
duration=d;
}
double Song::getDuration()
{
return duration;
}
#endif // SONG_CLASS
//FOR THE .CPP
I DO NOT KNOW HOW TO DISPLAY IT THERE.
CAN ANYONE HELP?
//file test.cpp
#include <iostream>
#include <fstream>
#include <string>
#include "song.h"
using namespace std;
int main()
{
return 0;
}
Edit & Run
//Postal.java - Jimmy Kurian
import java.util.Scanner;
public class Postal
{
public int num2; // 10000 digit
public int num3; // 1000 digit
public int num4; // 100 digit
public int num5; // 10 digit
public int num6; // 1 digit
public int checkDig; // check digit
public static int num;
public static String temp;
public static int menu;
public static int zip;
public static String bar0;
public static String bar1;
public static String bar2;
public static String bar3;
public static String bar4;
public static String bar5;
public static String bar6;
public static String bar7;
public static String bar8;
public static String bar9;
public static String str;
//Song Class
#ifndef SONG_CLASS
#define SONG_CLASS
using namespace std;
class Song
{
private:
string title; //dynamic allocation
string album;
string genre;
string artist;
double durationn;
public:
Song();
void setTitle(string t);
void setDuration(double d);
void setAlbumName(string a);
void setGenre(string g);
void setArtist(string a);
string getTitle();
string getAlbum()const;
string getGenre()const;
string getArtist()const;
double getDuration)(); //accessor
};
//constructor
Song::Song() //constructor
{
title="";
album="";
genre="";
artist="";
duration=0;
}
//accessor for name
string Song::getTitle()
{
return title;
}
//mutator
void Song::setTitle(string t)
{
title=t;
}
//accessor for name
string Song::getAlbum()
{
return album;
}
//mutator
void Song::setAlbumName(string a)
{
album=a;
}
//accessor for name
string Song::getGenre()
{
return genre;
}
//mutator
void Song::setGenre(string g)
{
genre=g;
}
//accessor for name
string Song::getArtist()
{
return artist;
}
//mutator
void Song::setArtist(string s)
{
artist=s;
}
void Song::setDuration(double d)
{
duration=d;
}
double Song::getDuration()
{
return duration;
}
#endif // SONG_CLASS
//FOR THE .CPP
I DO NOT KNOW HOW TO DISPLAY IT THERE.
CAN ANYONE HELP?
//file test.cpp
#include <iostream>
#include <fstream>
#include <string>
#include "song.h"
using namespace std;
int main()
{
return 0;
}
Edit & Run
//Postal.java - Jimmy Kurian
import java.util.Scanner;
public class Postal
{
public int num2; // 10000 digit
public int num3; // 1000 digit
public int num4; // 100 digit
public int num5; // 10 digit
public int num6; // 1 digit
public int checkDig; // check digit
public static int num;
public static String temp;
public static int menu;
public static int zip;
public static String bar0;
public static String bar1;
public static String bar2;
public static String bar3;
public static String bar4;
public static String bar5;
public static String bar6;
public static String bar7;
public static String bar8;
public static String bar9;
public static String str;
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.