C++ cin operator

//

//  CCInPut.hpp

//  CComplex

//

//  Created by Mr.peng on 2/21/19.

//  Copyright © 2019 Mr.peng. All rights reserved.

//

#ifndef CCInPut_hpp

#define CCInPut_hpp

#include <iostream>

//COutPut in;

class CCInPut{

private:

public:

    

    CCInPut(){

        

    }

    ~CCInPut(){

        

    }

    

    CCInPut& operator>>(int &id){

        //printf("")

        scanf("%d",&id);

        return *this;

    }

    

    CCInPut& operator>>(short s){

        printf("%d",s);

        return *this;

    }

    

    CCInPut& operator>>(char c){

        //printf("%c",c);

        scanf("%C",c);

        return *this;

    }

    

    CCInPut& operator>>(const char* str){

        fflush(stdin);  //清理缓存

        scanf("%s",str);

        return *this;

    }

    CCInPut& operator>>(float &f){

       // printf("%f",f);

        scanf("%f",f);

        return *this;

    }

    

    CCInPut& operator>>(double &dl){

        //printf("%lf",dl);

        scanf("%lf",&dl);

        return *this;

    }

    

};

#endif /* CCInPut_hpp */

猜你喜欢

转载自blog.csdn.net/pengkejie1314520/article/details/87881588