Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
aa
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
//g++ 5.4.0 #include <iostream> #include <stack> #include <vector> struct mystack : public std::stack<int, std::vector<int> > { void reserve(size_type n) { c.reserve(n); } std::size_t size() const noexcept { return c.size(); } const int& operator[](const std::size_t i) const noexcept { return c[i]; } }; int main() { mystack x; x.push(1); x.push(2); x.push(3); std::cout << x.size() << '\n'; for(std::size_t i = 0; i < x.size(); ++i) std::cout << x[i] << ' '; std::cout << '\n'; x.pop(); for(std::size_t i = 0; i < x.size(); ++i) std::cout << x[i] << ' '; std::cout << '\n'; std::cout << x.size() << '\n'; }
g++
Show compiler warnings
[
+
] Compiler args
[
+
]
Show input
Compilation time: 0.53 sec, absolute running time: 0.12 sec, cpu time: 0.05 sec, memory peak: 3 Mb, absolute service time: 0,65 sec
edit mode
|
history
|
discussion
3 1 2 3 1 2 2