高人们问一下,这段代码是怎末调用这个成员函数operator+()的?

  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class complex{
  5. public:
  6. complex();
  7. complex(double real, double imag);
  8. public:
  9. //声明运算符重载
  10. complex operator+(const complex &A) const;
  11. void display() const;
  12. private:
  13. double m_real; //实部
  14. double m_imag; //虚部
  15. };
  16.  
  17. complex::complex(): m_real(0.0), m_imag(0.0){ }
  18. complex::complex(double real, double imag): m_real(real), m_imag(imag){ }
  19.  
  20. //实现运算符重载
  21. complex complex::operator+(const complex &A) const{
  22. complex B;
  23. B.m_real = this->m_real + A.m_real;
  24. B.m_imag = this->m_imag + A.m_imag;
  25. return B;
  26. }
  27.  
  28. void complex::display() const{
  29. cout<<m_real<<" + "<<m_imag<<"i"<<endl;
  30. }
  31.  
  32. int main(){
  33. complex c1(4.3, 5.8);
  34. complex c2(2.4, 3.7);
  35. complex c3;
  36. c3 = c1 + c2;
  37. c3.display();
  38.  
  39. return 0;
  40. }

追问:大佬门问一下,对这段代码的解释是:当执行c3 = c1 + c2;语句时,编译器检测到+号左边(+号具有左结合性,所以先检测左边)是一个 complex 对象,就会调用成员函数operator+(),也就是转换为下面的形式:c3 = c1.operator+(c2);        我的问题:当这段代码执行到第36行:c3 = c1 + c2;后,他是怎末调用第10行:complex operator+(const complex &A) const;的函数的?一般调用函数不是用  对象.(函数名)  或者 对象->(函数名)吗,我现在的理解是当遇到重载符号+号和左侧是一个operator的对象就会调用这个重载函数,实在是云里雾里

这个代码是定义了一个复数类,通过运算符重载,用+号实现复数的加法运算  运行的结果是:6.7 + 9.5i