Hi, I am writing a program to perform nodal analysis and I need complex input for phasors and impedances. I have declared the variable and I want to read its value from standard input:
Hovever the only way for it to accept a complex input is if I write it in the form:Code:complex <float> VoltageSource; cout << "Enter voltage source value: " << endl; cin >> source;
(real,imag).
My question: is there any way to make it read "2 3" or "2+3i" to give me 2+3i? Is there a way to read only to the real or imaginary part of a given complex variable? VoltageSource.real and VoltageSource.imag give me an error, so I concluded that they are probably used for output only.