淘先锋技术网

首页 1 2 3 4 5 6 7

// 输入输出流运算重载模板


#include <iostream>


class Test {

private:

    int testMenber1;

    double testMenber2;

public:

    friend std::istream &operator >>(std::istream &stream, Test &temp) {

        std::cin >> temp.testMenber1 >> temp.testMenber2;

        return stream;

    }

    friend std::ostream &operator <<(std::ostream &stream, Test &temp) {

        std::cout << "menber1 = " << temp.testMenber1 << "\nmenber2 = " << temp.testMenber2 << std::endl;

        return stream;

    }

};


int main(int argc, const char *argv[]) {

    Test tt;

    std::cin >> tt;

    std::cout << tt;

    return 0;

}