Please read this program
When I run this program, I find that the result of the sentence:a=*p+*++p is out of my expectation, I think the result is that a.real()=4 and a.imag=6. But when I debug this program the result is something I can not understand.
Please help me to find the root of the problem.
Thanks!
#include<iostream>
#include<complex>
using namespace std;
void main()
{
complex<double>a(2, 3);
complex<float>b(0, 3);
complex<int>c;
complex<double>d(a);
complex<double>e[2]={complex<double>(1, 2), complex<double>(3, 4)};
complex<double>*p = &e[0];
a+=d;
cout<<a<<endl;
a=*p+*++p;
cout<<a<<endl;
double x = a.real();
double y = a.imag();
cout<<x<<" "<<y<<endl;
}