I searched online and was told that constructor in C++ doesn’t have a return value, but we do have such code:
class A {
public:
A() {}
};
int main() {
A a = A();
return 0;
}
Or,
void f() {
throw A();
}
int main() {
try {
f();
} catch (A& a) {
cout << "catched!" << endl;
}
return 0;
}
It does look strange. I wonder if a constructor will return something implicitly.