《C++ STL编程实战》读书笔记(一)

一.

//Ex1_01
//using iterators
//2019年9月28日15:53:10

#include 
#include 
#include 

using namespace std;

int main()
{
    double data [] = {2.5,4.5,6.5,5.5,8.6};
    std::cout <<"The array contains"<
//Ex1_02
//using stream iterator
//2019年9月28日16:01:06

#include 
#include 
#include 

using namespace std;

int main()
{
    std::cout <<"Enter values separated by space use Ctrl+Z to stop"<(std::cin),std::istream_iterator(),0.0)<
//ex1_03
//passing function to an algorithm
//2019年9月28日16:29:23

#include 
#include 
#include 
#include 

using namespace std;

class Root
{
public:
    double operator()(double x){
        return sqrt(x);
    };
};

int main()
{
    double data[] = {1.5,2.5,3.5,4.5,5.5};

    //passing a function object
    Root root;
    cout<<"Square roots of this data:"<(cout," "),root);
    cout<(cout," "),[](double x){return x*x*x;});
    cout< as argument
    function op {[](double x){return x*x;}};
    cout<<"Squares of this data:"<(cout," "),op);
    cout<(cout," "),[&op](double x){return op(x)*op(x);});
    cout<

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

你可能感兴趣的:(C++,STL,学习笔记)