The most frequently used buttons in a browser are the forwar
Solution
PROGRAM CODE:
#include <iostream>
using namespace std;
class BrowsingHistory
{
private:
string URL;
BrowsingHistory *next;
BrowsingHistory *prev;
public:
BrowsingHistory()
{
URL = \"\";
next = NULL;
prev = NULL;
}
BrowsingHistory(string url)
{
URL = url;
next = NULL;
prev = NULL;
}
BrowsingHistory(BrowsingHistory *bh)
{
URL = bh->URL;
next = bh->next;
prev = bh->prev;
}
string currentPage()
{
return URL;
}
void newPage()
{
cout<<\"Enter the next address: \";
string nexturl;
cin>>nexturl;
next = new BrowsingHistory(nexturl);
prev = new BrowsingHistory(this);
next->next = new BrowsingHistory(\"End of history\");
}
string forward()
{
BrowsingHistory current = this;
this->URL = current.next->URL;
this->next = current.next->next;
this->prev = ¤t;
return this->URL;
}
string backward()
{
if(prev == NULL)
return \"Beginning of history\";
else
{
BrowsingHistory previous = this->prev;
BrowsingHistory current = this;
this->URL = previous.URL;
this->next = ¤t;
this->prev = previous.prev;
return this->URL;
}
}
void display()
{
cout<<\"\ Browsing History: \"<<endl;
BrowsingHistory current = this;
while(current.prev != NULL)
{
current = current.prev;
}
while(current.URL != \"End of history\")
{
cout<<current.URL<<endl;
current = current.next;
}
}
}*his;
int main() {
his = new BrowsingHistory(\"www.google.com\");
cout<<\"Current Page: \"<<his->currentPage()<<\"\ \";
his->newPage();
cout<<\"\ Current Page: \"<<his->currentPage()<<\"\ \";
cout<<\"\ Going forward: \"<<his->forward();
cout<<\"\ Going backward: \"<<his->backward();
cout<<\"\ Displaying the history\"<<endl;
his->display();
return 0;
}
OUTPUT:

