以下の内容はhttps://higepon.hatenablog.com/entry/20110605/1307233265より取得しました。


C++ の参照

#include <stdio.h>
#include <string>

using namespace std;

class Hoge {
private:
    string& s_;
public:
    Hoge(string& s) : s_(s) {}

    void print() {
        printf("<%s>\n", s_.c_str());
    }
};

int main()
{
    string data("abc");
    Hoge hoge(data);
    hoge.print();
    data.clear();
    hoge.print();
    data += "def";
    hoge.print();
    data = "cde";
    hoge.print();
}

実行結果

% g++ test.cpp && ./a.out
<abc>
<>
<def>
<cde>



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

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