C++默认构造器

来源:互联网 发布:穆斯林党员 知乎 编辑:程序博客网 时间:2024/06/03 22:06
#include <iostream>#include <string>using namespace std;class Example3 {    string data;public:    Example3 (const string& str) : data(str) {}    Example3 () {}    const string& content () const {return data;}};int main(int argc, char const *argv[]){    Example3 foo;    Example3 bar ("Test");    cout << "bar's content: " << bar.content() << endl;    return 0;}
原创粉丝点击