编译就是通不过,不知道为啥
大家好。我是Qt初学者,我写了个小程序,我建的是Qt控制台应用程序,但是编译出错,不知道该怎么改,请大家帮忙。 程序代码:
#include #include using std::cout; using std::endl; class Employee : public QObject { Q_OBJECT public: Employee(int); int getSalary() const; signals: void salaryChanged(int); public slots: void setSalary(int); private: int salary; }; Employee::Employee(int salary) { this->salary = salary; connect(this,SIGNAL(salaryChanged(int)),this,SLOT(setSalary(int))); } int Employee::getSalary() const { return salary; } void Employee::setSalary(int newSalary) { if(newSalary != salary) { salary = newSalary; emit salaryChanged(newSalary); } } int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); Employee e(3200); e.setSalary(4500); return a.exec(); }编译结果如下:
[local]1[/local]