fork download
  1. #include <stack>
  2. #include <iostream>
  3.  
  4. class my_stack : public std::stack< int > {
  5. public:
  6. using std::stack<int>::c; // expose the container
  7. };
  8.  
  9. int main() {
  10. my_stack blah;
  11. blah.push( 1 );
  12. blah.push( 2 );
  13. int sum = 0;
  14. for(int i=0;i<blah.size();i++){
  15. sum+=blah.c[i];
  16. }
  17.  
  18. std::cout<<sum<<std::endl;
  19.  
  20.  
  21. }
  22.  
Success #stdin #stdout 0s 4548KB
stdin
Standard input is empty
stdout
3