【发布时间】:2023-04-03 19:20:01
【问题描述】:
我期待输出 2、3,但我得到了垃圾值。这是为什么呢?
这是我的代码:
#include <iostream>
using namespace std;
class A
{
public:
int a, b;
A()
{
cout << a << " " << b;
}
A(int x, int y)
{
a = x;
b = y;
A(); // calling the default constructor
}
};
int main()
{
A ob(2, 3);
return 0;
}
【问题讨论】:
标签: c++ constructor garbage