1. Let's look at the following:
#include <iostream.h>
class a {
private:
int x;
public:
a() {x=0;}
a(int z) {x=z;}
};
int main() {
a test1; // first command
a test2(3); // second command
a test3(); // third command
return (0);
}
I understand why the first and second command creates no error. But I dont understand why the third command always creates error? Is it normal? Do there exist any method to eliminate the problem? To me, the third command is virtually the same as the first command. But now the thrid creates the error but not the first one. So strange.
2. Let's look at the following:
#include <iostream.h>
void a() { // do something}
int main () {
a; // first command
a(); // second command
a(void); // third command
return (0);
}
Now, the first command creates error but not the second one. I want to know why. And what will happen to the third command?
Thanks for answering.