ぼるじょあがC/C++の宿題を片づけますYO! 68代目 at TECH
[2ch|▼Menu]
127:デフォルトの名無しさん
07/06/17 00:56:20
>>125
とりあえず名前だけ作った。
適当に関数追加するだけなんだし自分で作って。

#include <iostream>
struct Creature {
private:
    const char *name;
public:
    void setName(const char *name) {
        this->name = name;
    }
    const char *getName() const {
        return name;
    }
};
struct Animal : public Creature {};
struct Human : public Creature {};
int main() {
    Animal animal;
    animal.setName("動物");
    std::cout << animal.getName() << std::endl;
    Human human;
    human.setName("人間");
    std::cout << human.getName() << std::endl;
    return 0;
}



次ページ
続きを表示
1を表示
最新レス表示
スレッドの検索
類似スレ一覧
話題のニュース
おまかせリスト
▼オプションを表示
暇つぶし2ch

4349日前に更新/401 KB
担当:undef