Application of STL stack in development

Source: Internet
Author: User

 

The stack has the following features: first-in-first-out. We can use it to temporarily store data. In the development of the canvas, I used the stack to save each step of the user's operations, when you click Cancel, you can extract the image from the stack and restore it. This is also the principle of browser forward and backward, but it only saves web pages. You can use the STL to easily use stacks instead of complex function definitions. Let's look at the following examples and hope that you can use the following examples to understand how to use the stacks in STL and how to use the stacks.

# Include <graphics. h>
# Include <iostream>
# Include <conio. h>
# Include <stack>
Using Namespace STD;
Int Main ()
{
Stack <image> S1;
Image IMG, HH;
Initgraph ( 600 , 600 );
// Screen push stack
Cleardevice ();
Getimage (& IMG, 0 , 0 , 600 , 600 );
S1.push (IMG );
// Drawing circle pressure Stack
Circle ( 100 , 100 ,50 );
Getimage (& IMG, 0 , 0 , 600 , 600 );
S1.push (IMG );
Getch ();
// Drawing line pressure Stack
Line ( 1 , 1 , 600 , 600 );
Getimage (& IMG, 0 , 0 , 600 , 600 );
S1.push (IMG );
Getch ();
// Clear Screen
Cleardevice ();
Getch ();
// Stack output in sequence
HH = s1.top ();
Putimage ( 0 ,0 , & HH );
Getch ();
S1.pop ();
HH = s1.top ();
Putimage ( 0 , 0 , & HH );
Getch ();
S1.pop ();
HH = s1.top ();
Putimage ( 0 , 0 , & HH );
Getch ();
S1.pop ();
}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.