ToDo:
#include <stdio.h>
#include <string>
using namespace std;
class Text {
public:
Text(string s) : s_(s) {}
virtual char firstCharacter() /* const */ {
return s_[0];
}
protected:
string s_;
};
class AnotherText : public Text {
public:
AnotherText(string s) : Text(s) {}
virtual char firstCharacter() {
return s_[1];
}
};
int main() {
Text* text = new AnotherText("foo");
// o
printf("%c\n", text->firstCharacter());
}
とかあって、 firstCharacter って const だろと思って Text の方だけにつけたら挙動が変わった。
30分ほど気付かなかった
(01:16)
| 前 | 2010年 3月 |
次 | ||||
| 日 | 月 | 火 | 水 | 木 | 金 | 土 |
| 1 | 2 | 3 | 4 | 5 | 6 | |
| 7 | 8 | 9 | 10 | 11 | 12 | 13 |
| 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| 21 | 22 | 23 | 24 | 25 | 26 | 27 |
| 28 | 29 | 30 | 31 | |||
全てリンクフリーです。 コード片は自由に使用していただいて構いません。 その他のものはGPL扱いであればあらゆる使用に関して文句は言いません。 なにかあれば下記メールアドレスへ。