c++ - QT : cannot call member without object when I have a virtual function -
I'm calling QT since another function
my.http: P>
virtual string whatday (string) {return "";} my function from the calendar: gregorian.h:
whatday (String) and my_whatDayButton_clicked () function from mainwindow.cpp MainWindow :: on_whatDayButton_clicked () {QString whatDayString; String matching; WhatDayString = ui- & gt; Linegate diy-> Text (); String Day = whatDayString.toUtf8 (). ConstData (); GetDay = calendarGregorian :: whatDay (days); }
But, when I am compiling .. it shows me this error:
Error: member can not call function 'virtual std :: string CalendarGregorian :: whatday (Std :: string) 'without object getDay = calendarGregorian :: whatDay (days); ^
Please .. I need help
calendar.h: < / P>
Fixed string whatday (string) {return "";} calendarGregorian.h:
class CalendarGregorian: Calendar {Public: static int superCalculationFactor = 276485; Int notSoGood; Static strings are formatted using whatday (string) {// superCalculationFactor // You can not use SOUDE! Return result; }} In this way you do not need the object to call the function. The problem here was that the objects need the object, while static functions can be said without any object.
But if you go this way, do not forget that you have access to static square variables, and not on objects variables.
Comments
Post a Comment