我創建了一個從字符串類公開繼承的新類。我希望超載派生類中的<
(小於)運算符。但是從重載函數我需要調用父類<
運算符。調用這個函數的語法是什麼?如果可能,我希望將該運算符作爲成員函數來實現。如何從重載函數調用父類成員函數?
在Java中有super
這個關鍵字。
我的代碼如下。
#include<iostream>
#include<string>
using namespace std;
class mystring:public string
{
bool operator<(const mystring ms)
{
//some stmt;
//some stmt;
//call the overloaded <(less than)operator in the string class and return the value
}
};
是''string'的std :: string'? –
是std :: string –
謝謝你的link.I需要在父類中調用less運算符的語法。 –