課程
/后端開發(fā)
/C++
/數(shù)據(jù)結(jié)構(gòu)探險(xiǎn)—棧篇
[]運(yùn)算符具體怎么實(shí)現(xiàn)的呀,有點(diǎn)困難
2018-03-01
源自:數(shù)據(jù)結(jié)構(gòu)探險(xiǎn)—棧篇 4-2
正在回答
template<typename T>
?int& MyStack<T>::operator[](int i) {
? ? ?return m_pBuffer[i];
}
我是這么實(shí)現(xiàn)的,但是好像行不通
報(bào)錯(cuò):?no match for 'operator[]' (operand types are 'char [17]' and 'MyStack<int>')|
但是我感覺這樣可以重載呀
舉報(bào)
棧,先入后出(FILO),帶領(lǐng)大家體會(huì)棧這種數(shù)據(jù)結(jié)構(gòu)的美妙
3 回答[]運(yùn)算符重載
4 回答運(yùn)算符重載的時(shí)候出錯(cuò)??
1 回答關(guān)于入棧的問題?
2 回答關(guān)于char num[]的疑問
2 回答重載到底實(shí)現(xiàn)了沒有?
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號(hào)-11 京公網(wǎng)安備11010802030151號(hào)
購(gòu)課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動(dòng)學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號(hào)
2018-03-02
template<typename T>
?int& MyStack<T>::operator[](int i) {
? ? ?return m_pBuffer[i];
}
我是這么實(shí)現(xiàn)的,但是好像行不通
報(bào)錯(cuò):?no match for 'operator[]' (operand types are 'char [17]' and 'MyStack<int>')|
但是我感覺這樣可以重載呀