y‰SŽÒнŒ}zC/C++Ž ..
98:ƒfƒtƒHƒ‹ƒg‚Ì–¼–³‚µ‚³‚ñ
08/03/16 00:26:29
>>92-97
‚ ‚肪‚Æ‚¤‚²‚´‚¢‚Ü‚·B
ƒAƒhƒoƒCƒX‚𑇂µ‚ÄŽÀ‘•‚µ‚Ă݂½‚̂ł·‚ªAƒRƒ“ƒpƒCƒ‹‚ª’Ê‚è‚Ü‚¹‚ñB
#include <iostream>
#include <vector>
using namespace std;
template <typename T>
class cvector : public std::vector<T> {
T operator[](const int n) const {
int index = (n >= 0) ? n : this->size()-n;
// assert(n >= 0);
return (*this)[index % this->size()];
}
};
int main(){
cvector<int> vec;
vec.push_back(11);
cout << vec[0];
return 0;
}
ƒRƒ“ƒpƒCƒ‹ƒGƒ‰[‚Í‚±‚¤‚Å‚·B
test.cpp:6: error: 'T cvector<T>::operator[](int) const [with T = int]' is private//T operator[](const int n) const {‚Ìs‚Å‚·B
test.cpp:15: error: within this context // cout << vec[0]; ‚Ìs‚Å‚·B
‚Ç‚¤‚©‚à‚¤‚·‚±‚µ‹³‚¦‚Ä‚‚¾‚³‚¢B
ŽŸƒy[ƒWÅVƒŒƒX•\ަƒXƒŒƒbƒh‚ÌŒŸõ—ÞŽ—ƒXƒŒˆê——˜b‘è‚̃jƒ…[ƒX‚¨‚Ü‚©‚¹ƒŠƒXƒg¥ƒIƒvƒVƒ‡ƒ“‚ð•\ަ‰É‚‚Ԃµ2ch
4980“ú‘O‚ÉXV/60 KB
’S“–:undef