"类#34没有默认构造函数;为什么需要?

时间:2017-02-19 06:44:30

标签: c++ class struct constructor default-constructor

struct point {
    int x; int y;
    point(int a, int b) {
        x = a;
        y = b;
    }
    int sum = x + y;
};
class circle {
public:
    point p;
    double r;
    circle(point a, double b) {
        p = a;
        r = b;
    }
    //circle(point a, double b) : p(a), r(b) {}; //no error
};

错误消息说"类点没有默认构造函数"出现在圆形构造函数中。为什么需要默认的构造函数?

0 个答案:

没有答案