This code compiles
class X{};
int main() {
X obj1;
X obj2(obj1);
}
However, this does not compile
class X{};
int main() {
X obj1(X());
X obj2(obj1);
}
By default all constructors are created. When i use flower brackets it work, but i want to know whats wrong with this particular code. Why the compiler says the following
test.cpp: In function ‘int main()’:
test.cpp:4:13: error: no matching function for call to ‘X::X(X (&)(X (*)()))’
4 | X obj2(obj1);
Aucun commentaire:
Enregistrer un commentaire