Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Blog
Simple use of function templete and namespace
// 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; }
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
queue-with-fixed-size
Org
pointer to template function
ThreadContext
Shultz_Lab1.CPP
Lazy String Tokenizer Class
Sort an array of 0s, 1s and 2s
Guess Number
410
ChiSq
stackse - search stackoverflow differently
Please log in to post a comment.