C++ Codes
Algorithms
Algorithm Analysis in C++
Beginners
Code Snippets
Graphics
Data Structures
File Manipulation
Games
Mathematics
Miscellaneous
Visual C++ Library
C++ > Visual C++ 5.0 Standard C++ Library sample source codes
Stack operatoreq - Equality operation on stacks
Stack operatoreq - Equality operation on stacks operator== Header <stack> template<class T, class Cont> bool operator==(const stack<T, Cont>&s1, const stack<T, Cont>&s2) ; Equality operation on stacks. Returns true if the elements in s1 and s2 are elementwise equal. The function returns the result of: s1.c == s2.c Sample #include <iostream> #include <stack> int main() { std::stack<int> s1, s2, s3, s4 ; int i ; for (i = 0; i < 10; i++) { s1.push(i) ; s2.push(i*i) ; s3.push(i*i*i) ; s4.push(i) ; } if (s1 == s4) std::cout << "s1 == s4" << std::endl ; if (s2 != s3) std::cout << "s2 != s3" << std::endl ; if(s2 < s3) std::cout << "s2 < s3" << std::endl ; if(s3 > s2) std::cout << "s3 > s2" << std::endl ; s4.push(29) ; if (s1 <= s4) std::cout << "after s4.push(29), s1 <= s4" << std::endl ; if (s3 >= s2) std::cout << "s3 >= s2" << std::endl ; return 0 ; } Program Output s1 == s4 s2 != s3 s2 < s3 s3 > s2 after s4.push(29), s1 <= s4 s3 >= s2
Privacy Policy
|
Link to Us
|
Links