Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help with the copy constructor of a linked stack.(in C++) .This this the code for the LStack class: template class LStack { private:

I need help with the copy constructor of a linked stack.(in C++) .This this the code for the LStack class:

template class LStack { private: //variable declaration static int const ARRAY_CAPACITY = 8;

SingleList list; int itop; int stack_size;

public: LStack(); LStack( LStack const & ); ~LStack();

bool empty() const; int size() const; int list_size() const;

Type top() const;

void swap( LStack & ); LStack &operator=( LStack ); void push( Type const &obj ); Type pop();

// Friends

template friend std::ostream &operator<<( std::ostream &, LStack const & ); };

template LStack::LStack(): stack_size( 0 ) { // Empty constructor } //copy constructor template LStack::LStack( LStack const &stack ): itop( stack.itop ), stack_size( stack.stack_size ) {

//NEED HELP WRITING THIS

}

SingleNode class:

template class SingleNode { private: Type element; SingleNode *next_node;

public: SingleNode( Type const &e = Type(), SingleNode *n = 0 );

Type retrieve() const; SingleNode *next() const;

friend class SingleList; };

SingleList class:

template class SingleList { private: //variable declaration SingleNode *list_head; SingleNode *list_tail; int list_size;

public: SingleList(); //constructor SingleList( SingleList const & ); //copy constructor ~SingleList(); //destructor

// Accessors

int size() const; bool empty() const;

Type front() const; Type back() const;

SingleNode *head() const; SingleNode *tail() const;

int count( Type const & ) const;

// Mutators

void swap( SingleList & ); SingleList &operator=( SingleList const & );

void push_front( Type const & ); void push_back( Type const & );

Type pop_front();

int erase( Type const & );

// Friends

template friend std::ostream &operator<<( std::ostream &, SingleList const & ); };

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Distributed Relational Database Architecture Connectivity Guide

Authors: Teresa Hopper

4th Edition

0133983064, 978-0133983067

More Books

Students also viewed these Databases questions