Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!