cin

c++学习cin的使用总结
cin属于istream类的对象(还没搞懂什么是类,c++萌新,大佬轻喷)
先说一下我为什么会写这篇博客:
下午照着c++primerplus做题的时候遇到一个难点,到网上找到答案之后发现
cin还有这么多用法`:

basic_istream& __CLR_OR_THIS_CALL operator>>(int& _Val) { // extract an int
    static_assert(sizeof(int) == sizeof(long), "Bad overflow assumptions due to sizeof(int) != sizeof(long)");
    long _Result = _Val;
    _Common_extract_with_num_get(_Result);
    _Val = _Result;
    return *this;
}

basic_istream& __CLR_OR_THIS_CALL operator>>(unsigned int& _Val) { // extract an unsigned int
    return _Common_extract_with_num_get(_Val);
}

basic_istream& __CLR_OR_THIS_CALL operator>>(long& _Val) { // extract a long
    return _Common_extract_with_num_get(_Val);
}

basic_istream& __CLR_OR_THIS_CALL operator>>(unsigned long& _Val) { // extract an unsigned long
    return _Common_extract_with_num_get(_Val);
}

basic_istream& __CLR_OR_THIS_CALL operator>>(long long& _Val) { // extract a long long
    return _Common_extract_with_num_get(_Val);
}

basic_istream& __CLR_OR_THIS_CALL operator>>(unsigned long long& _Val) { // extract an unsigned long long
    return _Common_extract_with_num_get(_Val);
}

basic_istream& __CLR_OR_THIS_CALL operator>>(float& _Val) { // extract a float
    return _Common_extract_with_num_get(_Val);
}

basic_istream& __CLR_OR_THIS_CALL operator>>(double& _Val) { // extract a double
    return _Common_extract_with_num_get(_Val);
}

basic_istream& __CLR_OR_THIS_CALL operator>>(long double& _Val) { // extract a long double
    return _Common_extract_with_num_get(_Val);
}

basic_istream& __CLR_OR_THIS_CALL operator>>(void*& _Val) { // extract a void pointer
    return _Common_extract_with_num_get(_Val);
}`

这些是我在头文件istreaml里面找到的,发现"<<"操作符和函数很类似,当输入符合参数类型的数据时,函数返回一个非零数,否则返回“0”。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值