fork download
  1. #include <iostream>
  2. #include <stack>
  3. #include <string>
  4.  
  5. int main() {
  6. std::stack <std::string> cards;
  7. std::string ch1;
  8.  
  9. cards.push("Ace");
  10. cards.push("King");
  11. cards.push("Queen");
  12. cards.push("Jack in the Jack");
  13.  
  14. std::cout << "Number of cards : " << cards.size() << std::endl;
  15.  
  16. ch1 = cards.top(); // Get the top card
  17.  
  18. std::cout << "Top of the Stack : " << ch1;
  19. }
  20.  
  21.  
Success #stdin #stdout 0s 3476KB
stdin
Standard input is empty
stdout
Number of cards : 4
Top of the Stack : Jack in the Jack