Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Good1
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
//Title of this code #include <iostream> #include <list> #include <memory> using namespace std; struct Node { int x; Node(int x) { this->x = int(x); } Node(const Node& n) { *this = Node(n); } }; typedef shared_ptr<Node> node_ptr; void print(list<node_ptr> l) { for (auto it = l.begin(); it != l.end(); ++it) cout << (*it)->x << " "; cout << endl; } template <class T1, class T2> class Prb { public: list<node_ptr> nodes; Prb& operator=(const Prb& p){ this->nodes = p.nodes; } }; int main() { list<node_ptr> a,b; a.push_back(node_ptr(new Node(1))); b.push_back(node_ptr(new Node(2))); a=b; a.push_back(node_ptr(new Node(3))); b.push_back(node_ptr(new Node(4))); print(a); print(b); Prb<int,int> A,B; A.nodes = a; B.nodes = b; A=B; A.nodes.push_back(node_ptr(new Node(5))); B.nodes.push_back(node_ptr(new Node(6))); print(A.nodes); print(B.nodes); }
g++
Show compiler warnings
[
+
] Compiler args
[
+
]
Show input
Compilation time: 0.78 sec, absolute running time: 0.15 sec, cpu time: 0 sec, memory peak: 3 Mb, absolute service time: 0.94 sec (cached)
fork mode
|
history
|
discussion
2 3 2 4 2 4 5 2 4 6