Get the App
SLTechnology News&Howtos  ›  Development  › 

How to write the code of C++ general stack

Shulou Source: shulou.com Published: 2022-06-03 05:43:00 09月16日 Update

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!

Tags: Data index type function code size operator operation clocking from small to large number small array user this is length example content function method Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Linux Microsoft Xiaomi OPPO Reno