#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <windows.h>
class math
{
public:
math(double a, double b)
{
_a = a;
_b = b;
}
math operator+(const math & m)
{
/*math temp;
temp._a = m._a + _a;
temp._a = m._b + _b;
return temp;*/
return math(_a + m._a, _b +m._b);
}
private:
double _a;
double _b;
};
int main()
{
math a(1.0,2.0);
math b(2.0, 3.0);
math ret;
ret = a + b;
}
为什么显示ret没有默认的构造函数
#include <stdio.h>
#include <windows.h>
class math
{
public:
math(double a, double b)
{
_a = a;
_b = b;
}
math operator+(const math & m)
{
/*math temp;
temp._a = m._a + _a;
temp._a = m._b + _b;
return temp;*/
return math(_a + m._a, _b +m._b);
}
private:
double _a;
double _b;
};
int main()
{
math a(1.0,2.0);
math b(2.0, 3.0);
math ret;
ret = a + b;
}
为什么显示ret没有默认的构造函数