目前共有1篇帖子。
字體大小:較小 - 100% (默認)  內容轉換:不轉換
 
點擊 回復
1068 0
【方法】C++在派生类中继承基类的重载函数
巨大八爪鱼
武林盟主 二十一級
回復
1樓 發表於:2016-6-20 21:15
#include <iostream>

using namespace std;

class Person
{
public:
    void show(const char *name)
    {
        cout << "My name is " << name << '.' << endl;
    }
};

class Student : public Person
{
public:
    using Person::show;
    void show(void)
    {
        cout << "I'm a student." << endl;
    }
};

int main(void)
{
    Person p;
    p.show("Tom");

    Student s;
    s.show();
    s.show("haha");

    return 0;
}


回覆帖子
內容:
用戶名: 您目前是匿名發表。
驗證碼:
看不清?換一張
(快捷鍵:Ctrl+Enter)
本帖信息
點擊數:1068 回複數:0
作者:巨大八爪鱼
最後回覆:巨大八爪鱼
最後回復時間:2016-6-20 21:15
公告板