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();
}

 

相关文章:

  • 2021-06-05
  • 2021-10-09
  • 2021-10-10
  • 2021-12-03
  • 2022-12-23
  • 2021-04-16
  • 2021-10-19
  • 2021-09-09
猜你喜欢
  • 2022-12-23
  • 2023-01-03
  • 2021-10-24
  • 2021-07-09
  • 2022-12-23
  • 2021-12-23
  • 2022-12-23
相关资源
相似解决方案