簡(jiǎn)介
c++調(diào)用方式:
父類名::方法名
QT調(diào)用方式:文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-543098.html
__super::方法文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-543098.html
一、c++子類調(diào)用父類的方式
#include <iostream>
using namespace std;
class Father
{
public:
void func()
{
cout << "Father::func()" << endl;
}
};
class Child : public Father
{
public:
void func()
{
cout << "Child::func()" << endl;
Father::func(); //way1
}
};
int main()
{
Child c;
c.func();
c.Father::func(); //way2
return 0;
}
輸出如下
Child::func()
Father::func()
Father::func()
二、QT 子類調(diào)用父類(當(dāng)然可以用c++的方式)
void QCalendarTimeEdit::mousePressEvent(QMouseEvent *event)
{
__super::mousePressEvent(event);
if (event->button() == Qt::LeftButton)
{
popCalendarTimeWidget();
}
}
到了這里,關(guān)于c++和QT子類調(diào)用父類方法的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!