#include <iostream>
using namespace std;
class A{
public:
A(){
cout << "Class A!";}
};
int main()
{
A a();
}
the above code does not call the constructor A :: A()
even though they have the same input parameters (none). however if, in the main function, I remove the parenthesis from
A a();
it calls the constructor.
so what is the difference between A a;
and A a();
i believe the question here is very similar maybe even the same however if some could explain in simpler terms I would be very grateful. Do the parentheses after the type name make a difference with new?
would declaring A a();
ever call a constructor, under any circumstances?
do parameterless constructors exist in c++, or is that the same as a default constructor?