Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to write the code of C++ general stack

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report