AdvC++ - zadanie z complex - tworzeniem liczb zespolonych różnych typów za pomocą template
This commit is contained in:
parent
05f5e5df3d
commit
80b9b35508
1 changed files with 14 additions and 0 deletions
|
|
@ -1 +1,15 @@
|
|||
#include <complex>
|
||||
#include <iostream>
|
||||
|
||||
template<typename T, typename U>
|
||||
std::complex<T> makeComplex(T a, U b){
|
||||
return std::complex<T>(a,b);
|
||||
}
|
||||
|
||||
int main(){
|
||||
std::complex<int> a = makeComplex(4,5);
|
||||
std::complex<double> b = makeComplex(3.0,5.2);
|
||||
std::complex<int> c = makeComplex(1,5.2);
|
||||
|
||||
std::cout << a << std::endl << b << std::endl << c << std::endl;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue