template class ComplexNumber {private:T real;T imaginary;
public:ComplexNumber(T r, T i) : real(r), imaginary(i) {}
};
int main() {ComplexNumber c1(3, 4);c1.display();
}
template class ComplexNumber {
private:
T real;
T imaginary;
public:
void display() {ComplexNumber(T r, T i) : real(r), imaginary(i) {}
std::cout << real << " + " << imaginary << "i" << std::endl;
}
};
int main() {
ComplexNumber<float> c2(2.5, 1.5);ComplexNumber c1(3, 4);
c1.display();
c2.display();
return 0;
}