为什么我们在创建按钮时使用*字符但是我们没有将它添加到app实例?
#include <QApplication>
#include <QPushButton>
int main(int argc,char *argv[])
{
QApplication app(argc,argv);
QPushButton *button = new QPushButton("Button Text");
QObject::connect(button,SIGNAL(clicked()),&app,SLOT(quit()));
button->show();
return app.exec();
}
Run Code Online (Sandbox Code Playgroud)
我们什么时候应该使用*,&,.,->?
.在想要访问struct变量的成员时使用.*当你想要声明指向某个东西的指针(例如结构)时,你应该使用它.&当你想从变量中获取某个东西时,你应该使用它.->当您想要从指针访问结构的成员时,您应该使用它.