Question
x I keep getting these two errors with this C++ code in a template: sequence4.h:96:33: error: redefinition of stack_sequence_4::sequence::size_type stack_sequence_4::sequence:: size() const typename sequence::size_type sequence::size()
x
I keep getting these two errors with this C++ code in a template: sequence4.h:96:33: error: redefinition of stack_sequence_4::sequence::size_type stack_sequence_4::sequence:: size() const typename sequence::size_type sequence::size() const ^ And check next comment. and sequence5.h:79:19: error: stack_sequence_4::sequence::size_type stack_sequence_4::sequence::size() const previously declared here size_type size( ) const {return first.size()+second.size();} ^
What am I doing wrong? I think the code is good beside these two parts. Here is the code:
#ifndef _STACK_SEQUENCE_H_ #define _STACK_SAVITCH_SEQUENCE_H_ #include
template
template
second.push(first.top()); first.pop(); } if(!second.empty()) //if there is atleast one element, get that, its the 1st of sequence { first.push(second.top()); second.pop(); } }
template
template
template
if(!second.empty()) //now we need to get next element from the second stack, check if its empty { first.push(second.top()); second.pop(); } else //second is empty , so no more next element, dump all element from first onto second . So //we now dont have any current element since we are clearing out first { while(first.size()>0) {
second.push(first.top()); first.pop(); } }
} template
template
template
second.push(first.top()); first.pop(); } } }
}
#endif
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