I have a class made up of several fields, and I have several constructors. I also have a constructor that doesn't take any parameters, but when I try to use it:
int main {
A a;
}
The compiler generates an error, while if I use it like this:
int main {
A a();
}
It's ok. What's that?
Thank you
The first main uses A's default constructor. The second one declares a function that takes no parameters and returns an A by value, which probably isn't what you intend.
So what does the definition of A look like and what is the error that the compiler generates?
Oh, and you need to provide a parameter list in the declaration of main: int main() { //... , not int main { //...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With