How to write the code of C++ general stack
C++ general stack code how to write, I believe that many inexperienced people do not know what to do, so this paper summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.
Post the code first:
# include "stdafx.h" template class STACK {public: void operator-- (int) {index--;} void operator- (long count) {index-=count;} void operator+ (T value) {Push (value) } long operator+= (T value) {return PushDifferent (value);} T&operator [] (long addr) {if (addrbasicLen=BASICLEN; this- > len=0; index=-1; data=NULL; for (long irightleft > = v.rightlighting problems-> rightleft=left) This- > right=right; this- > flag=flag;} public: enum {WITHIN,WITHOUT}; long left,right; int flag;}
In this class, the = = operator is overloaded and the return value is of type Bool, so data of type RANGE can be used in PushDifferent and + =.
After reading the above, have you mastered the method of how to write C++ general stack code? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!