码迷,mamicode.com
首页 > 其他好文 > 详细

使用引用限定符的例子

时间:2014-08-24 23:27:13      阅读:232      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   os   使用   io   div   log   amp   

13.57 编写Foo类。

Foo.h

#ifndef FOO_H
#define FOO_H
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

class Foo
{
public:
    Foo sorted() &&;
    Foo sorted() const &;
private:
    vector<int> data;
};
#endif // FOO_H

Foo.cpp

#include"Foo.h"

Foo Foo::sorted() &&
{
    sort(data.begin(),data.end());
    return *this;
}

Foo Foo::sorted() const &
{
    cout<<"sorted&"<<endl;
    //sort(ret.data.begin(),ret.data.end());
    return Foo(*this).sorted();
}

 

使用引用限定符的例子

标签:style   blog   color   os   使用   io   div   log   amp   

原文地址:http://www.cnblogs.com/wuchanming/p/3933766.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!