当我尝试编译以下代码时:
class a {
int i;
public :
a(int);
};
class b {
a mya;
int j;
public:
b(int);
};
a::a(int i2) {
i=i2;
}
b::b(int i2) {
mya=a(i2);
j=2*i2;
}
int main() {
}
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
prog.cpp:21:12: error: no matching function for call to ‘a::a()
b::b(int i2) {
^
prog.cpp:17:1: note: candidate: ‘a::a(int)
a::a(int i2) {
^
prog.cpp:17:1: note: candidate expects 1 argument, 0 provided
prog.cpp:1:7: note: candidate: ‘constexpr a::a(const a&)’
class a {
^
prog.cpp:1:7: note: candidate expects 1 …Run Code Online (Sandbox Code Playgroud)