trainings/AdvancedCppV2/Presentation/exercises/complex/complex.cpp

15 lines
373 B
C++

#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;
}