以下の内容はhttps://bleis-tift.hatenablog.com/entry/20090722/1248255877より取得しました。


C++ の struct はデフォルトで public 継承

って、案外知られてないみたいですね。
どういうことかと言うと、

#include <iostream>

int main()
{
    class hoge
    {
    public:
        void f() { std::cout << "hoge" << std::endl; }
    };

    // class ex_hoge : hoge {};だと、eh.f()でエラー
    struct ex_hoge : hoge {};

    ex_hoge eh;
    eh.f();
}

これがコンパイルできる、ということです。
まぁ、あまり知られていないと言うことで、

struct ex_hoge : public hoge {};

としとくのが無難なのかも。




以上の内容はhttps://bleis-tift.hatenablog.com/entry/20090722/1248255877より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14