Please consider the below code.
1 #include <QApplication>
2 #include <QLabel>
3 int main(int argc, char *argv)
5 QApplication app(argc, argv);
6 QLabel *label = new QLabel("Hello Qt!");
8 return app.exec();
Now, I'm abit doubtful about line 5. According to the book(from which I extracted this code), it is said that QApplication in line 5 is a constructor. Now my questions are:
1. Every constructor should have a class (to which it belongs). So where is the class of this constructor?
2. Assuming that there IS a class for this constructor, then why the name of the constructor doesn't matches with the class to which it belongs?? I think that this is the rule for every constructor that the it should share the same name with the class to which it belongs. Here, we can see that the constructor is named QApplication app(argc, argv). [Assuming that the class name is QApplication.
Please clarify my doubts. I have quite basic knowledge of C++. So if I lack any basic points about constructor, I apologize and therefore request you to help me understand those missing points.