class foo {
public:
int a;
int b;
foo(int a_, int b_) : a(a_), b(b_) {}
};
int main() {
foo f;
}
when I try to compile the above code snippet, I got error message as below:
foo.cc: In function 'int main()'
foo.cc:12: error: no matching function for call to 'main()::foo::foo()'
foo.cc:10: note: candidates are: main()::foo::foo(int, int)
foo.cc:6: note: main()::foo::foo(const main()::foo&)
but if I comment the file of explicit constructor with two integer prarmeters, then the code can be compiled. I guess the rule behind the magic is that when you explicite declare constructor with parameters, c++ compilor will not atuomatically generate a default constructor with no parameters for you.
Am I right? If am right, why does c++ has such behaviour? thanks in advance.