Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Simple use of function templete and namespace
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
// Simple use of function templete and namespace #include<iostream> using namespace std; namespace first { int i,j,k; } namespace second{ double i,j,k; } template<typename T> T sum(T a, T b) { T result; result= a+b; return result; } int main() { using namespace second; first::i=4,first::j=6; first::k=sum<int>(first::i,first::j); cout<<endl<<"K= "<<first::k<<endl; i=8.345,j=879.45; k=sum<double>(i,j); cout<<endl<<"k= "<<k<<endl; return 0; }
g++
Show compiler warnings
[
+
] Compiler args
[
+
]
Show input
Compilation time: 0.31 sec, absolute running time: 0.04 sec, cpu time: 0 sec, memory peak: 3 Mb, absolute service time: 0.36 sec
fork mode
|
history
|
discussion
K= 10 k= 887.795