| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 640 人关注过本帖
标题:计算计上出现一些代码,不知道是做什么的,望各位解释哈,谢了
只看楼主 加入收藏
zhj123
Rank: 2
等 级:论坛游民
帖 子:39
专家分:21
注 册:2010-8-31
结帖率:90.91%
收藏
已结贴  问题点数:5 回复次数:4 
计算计上出现一些代码,不知道是做什么的,望各位解释哈,谢了
// ostream standard header

#if     _MSC_VER > 1000
#pragma once
#endif

#ifndef _OSTREAM_
#define _OSTREAM_
#include <ios>

#ifdef  _MSC_VER
#pragma pack(push,8)
#endif  /* _MSC_VER */
        // I/O exception macros
 #define _TRY_IO_BEGIN    _TRY_BEGIN
 #define _CATCH_IO_END    _CATCH_ALL \
    setstate(ios_base::badbit, true); _CATCH_END
 #define _CATCH_IO_(x)    _CATCH_ALL \
    (x).setstate(ios_base::badbit, true); _CATCH_END
_STD_BEGIN
        // TEMPLATE CLASS basic_ostream
template<class _E, class _Tr = char_traits<_E> >
    class basic_ostream : virtual public basic_ios<_E, _Tr> {
public:
    typedef basic_ostream<_E, _Tr> _Myt;
    typedef basic_ios<_E, _Tr> _Myios;
    typedef basic_streambuf<_E, _Tr> _Mysb;
    typedef ostreambuf_iterator<_E, _Tr> _Iter;
    typedef num_put<_E, _Iter> _Nput;
    explicit basic_ostream(basic_streambuf<_E, _Tr> *_S,
        bool _Isstd = false, bool _Doinit = true)
        {if (_Doinit)
            init(_S, _Isstd); }
    basic_ostream(_Uninitialized)
        {_Addstd(); }
    virtual ~basic_ostream()
        {}
    class sentry {
    public:
        explicit sentry(_Myt& _Os)
            : _Ok(_Os.opfx()), _Ostr(_Os) {}
        ~sentry()
            {if (!uncaught_exception())
                _Ostr.osfx(); }
        operator bool() const
            {return (_Ok); }
    private:
        bool _Ok;
        _Myt& _Ostr;
        };
    bool opfx()
        {if (good() && tie() != 0)
            tie()->flush();
        return (good()); }
    void osfx()
        {if (flags() & unitbuf)
            flush(); }
    _Myt& operator<<(_Myt& (__cdecl *_F)(_Myt&))
        {return ((*_F)(*this)); }
    _Myt& operator<<(_Myios& (__cdecl *_F)(_Myios&))
        {(*_F)(*(_Myios *)this);
        return (*this); }
    _Myt& operator<<(ios_base& (__cdecl *_F)(ios_base&))
        {(*_F)(*(ios_base *)this);
        return (*this); }
    _Myt& operator<<(_Bool _X)
        {iostate _St = goodbit;
        const sentry _Ok(*this);
        if (_Ok)
            {const _Nput& _Fac = _USE(getloc(), _Nput);
            _TRY_IO_BEGIN
            if (_Fac.put(_Iter(rdbuf()), *this,
                fill(), _X).failed())
                _St |= badbit;
            _CATCH_IO_END }
        setstate(_St);
        return (*this); }
    _Myt& operator<<(short _X)
        {iostate _St = goodbit;
        const sentry _Ok(*this);
        if (_Ok)
            {const _Nput& _Fac = _USE(getloc(), _Nput);
            fmtflags _Bfl = flags() & basefield;
            long _Y = (_Bfl == oct || _Bfl == hex)
                ? (long)(unsigned short)_X : (long)_X;
            _TRY_IO_BEGIN
            if (_Fac.put(_Iter(rdbuf()), *this,
                fill(), _Y).failed())
                _St |= badbit;
            _CATCH_IO_END }
        setstate(_St);
        return (*this); }
    _Myt& operator<<(unsigned short _X)
        {iostate _St = goodbit;
        const sentry _Ok(*this);
        if (_Ok)
            {const _Nput& _Fac = _USE(getloc(), _Nput);
            _TRY_IO_BEGIN
            if (_Fac.put(_Iter(rdbuf()), *this,
                fill(), (unsigned long)_X).failed())
                _St |= badbit;
            _CATCH_IO_END }
        setstate(_St);
        return (*this); }
    _Myt& operator<<(int _X)
        {iostate _St = goodbit;
        const sentry _Ok(*this);
        if (_Ok)
            {const _Nput& _Fac = _USE(getloc(), _Nput);
            fmtflags _Bfl = flags() & basefield;
            long _Y = (_Bfl == oct || _Bfl == hex)
                ? (long)(unsigned int)_X : (long)_X;
            _TRY_IO_BEGIN
            if (_Fac.put(_Iter(rdbuf()), *this,
                fill(), _Y).failed())
                _St |= badbit;
            _CATCH_IO_END }
        setstate(_St);
        return (*this); }
    _Myt& operator<<(unsigned int _X)
        {iostate _St = goodbit;
        const sentry _Ok(*this);
        if (_Ok)
            {const _Nput& _Fac = _USE(getloc(), _Nput);
            _TRY_IO_BEGIN
            if (_Fac.put(_Iter(rdbuf()), *this,
                fill(), (unsigned long)_X).failed())
                _St |= badbit;
            _CATCH_IO_END }
        setstate(_St);
        return (*this); }
    _Myt& operator<<(long _X)
        {iostate _St = goodbit;
        const sentry _Ok(*this);
        if (_Ok)
            {const _Nput& _Fac = _USE(getloc(), _Nput);
            _TRY_IO_BEGIN
            if (_Fac.put(_Iter(rdbuf()), *this,
                fill(), _X).failed())
                _St |= badbit;
            _CATCH_IO_END }
        setstate(_St);
        return (*this); }
    _Myt& operator<<(unsigned long _X)
        {iostate _St = goodbit;
        const sentry _Ok(*this);
        if (_Ok)
            {const _Nput& _Fac = _USE(getloc(), _Nput);
            _TRY_IO_BEGIN
            if (_Fac.put(_Iter(rdbuf()), *this,
                fill(), _X).failed())
                _St |= badbit;
            _CATCH_IO_END }
        setstate(_St);
        return (*this); }
    _Myt& operator<<(float _X)
        {iostate _St = goodbit;
        const sentry _Ok(*this);
        if (_Ok)
            {const _Nput& _Fac = _USE(getloc(), _Nput);
            _TRY_IO_BEGIN
            if (_Fac.put(_Iter(rdbuf()), *this,
                fill(), (double)_X).failed())
                _St |= badbit;
            _CATCH_IO_END }
        setstate(_St);
        return (*this); }
    _Myt& operator<<(double _X)
        {iostate _St = goodbit;
        const sentry _Ok(*this);
        if (_Ok)
            {const _Nput& _Fac = _USE(getloc(), _Nput);
            _TRY_IO_BEGIN
            if (_Fac.put(_Iter(rdbuf()), *this,
                fill(), _X).failed())
                _St |= badbit;
            _CATCH_IO_END }
        setstate(_St);
        return (*this); }
    _Myt& operator<<(long double _X)
        {iostate _St = goodbit;
        const sentry _Ok(*this);
        if (_Ok)
            {const _Nput& _Fac = _USE(getloc(), _Nput);
            _TRY_IO_BEGIN
            if (_Fac.put(_Iter(rdbuf()), *this,
                fill(), _X).failed())
                _St |= badbit;
            _CATCH_IO_END }
        setstate(_St);
        return (*this); }
    _Myt& operator<<(const void *_X)
        {iostate _St = goodbit;
        const sentry _Ok(*this);
        if (_Ok)
            {const _Nput& _Fac = _USE(getloc(), _Nput);
            _TRY_IO_BEGIN
            if (_Fac.put(_Iter(rdbuf()), *this,
                fill(), _X).failed())
                _St |= badbit;
            _CATCH_IO_END }
        setstate(_St);
        return (*this); }
    _Myt& operator<<(_Mysb *_Pb)
        {iostate _St = goodbit;
        bool _Copied = false;
        const sentry _Ok(*this);
        if (_Ok && _Pb != 0)
            for (int_type _C = _Tr::eof(); ; _Copied = true)
                {_TRY_BEGIN
                _C = _Tr::eq_int_type(_Tr::eof(), _C)
                    ? _Pb->sgetc() : _Pb->snextc();
                _CATCH_ALL
                    setstate(failbit);
                    _RERAISE;
                _CATCH_END
                if (_Tr::eq_int_type(_Tr::eof(),_C))
                    break;
                _TRY_IO_BEGIN
                    if (_Tr::eq_int_type(_Tr::eof(),
                        rdbuf()->sputc(_Tr::to_char_type(_C))))
                        {_St |= badbit;
                        break; }
                _CATCH_IO_END }
        width(0);
        setstate(!_Copied ? _St | failbit : _St);
        return (*this); }
    _Myt& put(_E _X)
        {iostate _St = goodbit;
        const sentry _Ok(*this);
        if (!_Ok)
            _St |= badbit;
        else
            {_TRY_IO_BEGIN
             if (_Tr::eq_int_type(_Tr::eof(),
                rdbuf()->sputc(_X)))
                _St |= badbit;
            _CATCH_IO_END }
        setstate(_St);
        return (*this); }
    _Myt& write(const _E *_S, streamsize _N)
        {iostate _St = goodbit;
        const sentry _Ok(*this);
        if (!_Ok)
            _St |= badbit;
        else
            {_TRY_IO_BEGIN
            if (rdbuf()->sputn(_S, _N) != _N)
                _St |= badbit;
            _CATCH_IO_END }
        setstate(_St);
        return (*this); }
    _Myt& flush()
        {iostate _St = goodbit;
        if (!fail() && rdbuf()->pubsync() == -1)
            _St |= badbit;
        setstate(_St);
        return (*this); }
    _Myt& seekp(pos_type _P)
        {if (!fail())
            rdbuf()->pubseekpos(_P, out);
        return (*this); }
    _Myt& seekp(off_type _O, ios_base::seekdir _W)
        {if (!fail())
            rdbuf()->pubseekoff(_O, _W, out);
        return (*this); }
    pos_type tellp()
        {if (!fail())
            return (rdbuf()->pubseekoff(0, cur, out));
        else
            return (streampos(_BADOFF)); }
    };


#ifdef _DLL
#pragma warning(disable:4231) /* the extern before template is a non-standard extension */
extern template class _CRTIMP basic_ostream<char, char_traits<char> >;
extern template class _CRTIMP basic_ostream<wchar_t, char_traits<wchar_t> >;
#pragma warning(default:4231) /* restore previous warning */
#endif        // _DLL


        // INSERTERS
template<class _E, class _Tr> inline
    basic_ostream<_E, _Tr>& __cdecl operator<<(
        basic_ostream<_E, _Tr>& _O, const _E *_X)
    {typedef basic_ostream<_E, _Tr> _Myos;
    ios_base::iostate _St = ios_base::goodbit;
    size_t _N = _Tr::length(_X);
    size_t _M = _O.width() <= 0 || _O.width() <= _N
        ? 0 : _O.width() - _N;
    const _Myos::sentry _Ok(_O);
    if (!_Ok)
        _St |= ios_base::badbit;
    else
        {_TRY_IO_BEGIN
        if ((_O.flags() & ios_base::adjustfield)
            != ios_base::left)
            for (; 0 < _M; --_M)
                if (_Tr::eq_int_type(_Tr::eof(),
                    _O.rdbuf()->sputc(_O.fill())))
                    {_St |= ios_base::badbit;
                    break; }
        if (_St == ios_base::goodbit
            && _O.rdbuf()->sputn(_X, _N) != _N)
            _St |= ios_base::badbit;
        if (_St == ios_base::goodbit)
            for (; 0 < _M; --_M)
                if (_Tr::eq_int_type(_Tr::eof(),
                    _O.rdbuf()->sputc(_O.fill())))
                    {_St |= ios_base::badbit;
                    break; }
        _O.width(0);
        _CATCH_IO_(_O) }
    _O.setstate(_St);
    return (_O); }
template<class _E, class _Tr> inline
    basic_ostream<_E, _Tr>& __cdecl operator<<(
        basic_ostream<_E, _Tr>& _O, _E _C)
    {typedef basic_ostream<_E, _Tr> _Myos;
    ios_base::iostate _St = ios_base::goodbit;
    const _Myos::sentry _Ok(_O);
    if (_Ok)
        {size_t _M = _O.width() <= 1 ? 0 : _O.width() - 1;
        _TRY_IO_BEGIN
        if ((_O.flags() & ios_base::adjustfield)
            != ios_base::left)
            for (; _St == ios_base::goodbit && 0 < _M; --_M)
                if (_Tr::eq_int_type(_Tr::eof(),
                    _O.rdbuf()->sputc(_O.fill())))
                    _St |= ios_base::badbit;
        if (_St == ios_base::goodbit
            && _Tr::eq_int_type(_Tr::eof(),
                _O.rdbuf()->sputc(_C)))
            _St |= ios_base::badbit;
        for (; _St == ios_base::goodbit && 0 < _M; --_M)
            if (_Tr::eq_int_type(_Tr::eof(),
                _O.rdbuf()->sputc(_O.fill())))
                _St |= ios_base::badbit;
        _CATCH_IO_(_O) }
    _O.width(0);
    _O.setstate(_St);
    return (_O); }
template<class _E, class _Tr> inline
    basic_ostream<_E, _Tr>& __cdecl operator<<(
        basic_ostream<_E, _Tr>& _O, const signed char *_X)
    {return (_O << (const char *)_X); }
template<class _E, class _Tr> inline
    basic_ostream<_E, _Tr>& __cdecl operator<<(
        basic_ostream<_E, _Tr>& _O, const signed char _C)
    {return (_O << (char)_C); }
template<class _E, class _Tr> inline
    basic_ostream<_E, _Tr>& __cdecl operator<<(
        basic_ostream<_E, _Tr>& _O, const unsigned char *_X)
    {return (_O << (const char *)_X); }
template<class _E, class _Tr> inline
    basic_ostream<_E, _Tr>& __cdecl operator<<(
        basic_ostream<_E, _Tr>& _O, const unsigned char _C)
    {return (_O << (char)_C); }
template<class _E, class _Tr> inline
    basic_ostream<_E, _Tr>& __cdecl operator<<(
        basic_ostream<_E, _Tr>& _O, const signed short *_X)
    {return (_O << (const wchar_t *)_X); }
        // MANIPULATORS
template<class _E, class _Tr> inline
    basic_ostream<_E, _Tr>&
        __cdecl endl(basic_ostream<_E, _Tr>& _O)
    {_O.put(_O.widen('\n'));
    _O.flush();
    return (_O); }
_CRTIMP inline basic_ostream<char, char_traits<char> >&
    __cdecl endl(basic_ostream<char, char_traits<char> >& _O)
    {_O.put('\n');
    _O.flush();
    return (_O); }
_CRTIMP inline basic_ostream<wchar_t, char_traits<wchar_t> >&
    __cdecl endl(basic_ostream<wchar_t,
        char_traits<wchar_t> >& _O)
    {_O.put('\n');
    _O.flush();
    return (_O); }
template<class _E, class _Tr> inline
    basic_ostream<_E, _Tr>&
        __cdecl ends(basic_ostream<_E, _Tr>& _O)
    {_O.put(_E('\0'));
    return (_O); }
_CRTIMP inline basic_ostream<char, char_traits<char> >&
    __cdecl ends(basic_ostream<char, char_traits<char> >& _O)
    {_O.put('\0');
    return (_O); }
_CRTIMP inline basic_ostream<wchar_t, char_traits<wchar_t> >&
    __cdecl ends(basic_ostream<wchar_t,
        char_traits<wchar_t> >& _O)
    {_O.put('\0');
    return (_O); }
template<class _E, class _Tr> inline
    basic_ostream<_E, _Tr>&
        __cdecl flush(basic_ostream<_E, _Tr>& _O)
    {_O.flush();
    return (_O); }
_CRTIMP inline basic_ostream<char, char_traits<char> >&
    __cdecl flush(basic_ostream<char, char_traits<char> >& _O)
    {_O.flush();
    return (_O); }
_CRTIMP inline basic_ostream<wchar_t, char_traits<wchar_t> >&
    __cdecl flush(basic_ostream<wchar_t,
        char_traits<wchar_t> >& _O)
    {_O.flush();
    return (_O); }

#ifdef _DLL
#pragma warning(disable:4231) /* the extern before template is a non-standard extension */

extern template _CRTIMP basic_ostream<char, char_traits<char> >& __cdecl operator<<(
       basic_ostream<char, char_traits<char> >&, const char *);
extern template _CRTIMP basic_ostream<char, char_traits<char> >& __cdecl operator<<(
       basic_ostream<char, char_traits<char> >&, char);
extern template _CRTIMP basic_ostream<char, char_traits<char> >& __cdecl operator<<(
       basic_ostream<char, char_traits<char> >&, const signed char *);
extern template _CRTIMP basic_ostream<char, char_traits<char> >& __cdecl operator<<(
       basic_ostream<char, char_traits<char> >&, const signed char);
extern template _CRTIMP basic_ostream<char, char_traits<char> >& __cdecl operator<<(
       basic_ostream<char, char_traits<char> >&, const unsigned char *);
extern template _CRTIMP basic_ostream<char, char_traits<char> >& __cdecl operator<<(
       basic_ostream<char, char_traits<char> >&, const unsigned char);
extern template _CRTIMP basic_ostream<wchar_t, char_traits<wchar_t> >& __cdecl operator<<(
       basic_ostream<wchar_t, char_traits<wchar_t> >&, const wchar_t *);
extern template _CRTIMP basic_ostream<wchar_t, char_traits<wchar_t> >& __cdecl operator<<(
       basic_ostream<wchar_t, char_traits<wchar_t> >&, wchar_t);
extern template _CRTIMP basic_ostream<wchar_t, char_traits<wchar_t> >& __cdecl operator<<(
       basic_ostream<wchar_t, char_traits<wchar_t> >&, const signed short *);

#pragma warning(default:4231) /* restore previous warning */
#endif        // _DLL

_STD_END
#ifdef  _MSC_VER
#pragma pack(pop)
#endif  /* _MSC_VER */

#endif /* _OSTREAM_ */

/*
 * Copyright (c) 1994 by P.J. Plauger.  ALL RIGHTS RESERVED.
 * Consult your license regarding permissions and restrictions.
 */


[ 本帖最后由 zhj123 于 2010-9-14 11:23 编辑 ]
搜索更多相关主题的帖子: 解释 代码 
2010-09-14 11:22
hahayezhe
Rank: 15Rank: 15Rank: 15Rank: 15Rank: 15
来 自:湖南张家界
等 级:贵宾
威 望:24
帖 子:1386
专家分:6999
注 册:2010-3-8
收藏
得分:0 
这人...你给个头文件让别人帮你解释?
2010-09-14 11:35
zhj123
Rank: 2
等 级:论坛游民
帖 子:39
专家分:21
注 册:2010-8-31
收藏
得分:0 
回复 2楼 hahayezhe
就是在调试其他程序的时候,出现错误,找错时一下子就出现这了,不晓得是怎么东东
c:\program files\microsoft visual studio\vc98\include\ostream(367) : see declaration of 'endl'
就是点击这条出现的
自己写的就是这:
#include<iostream>
using namespace std;
int main()
{
    int i=5,j=10,k=20;
    cout<<(i<j)&&(j>k)<<endl;
    return 0;
}


[ 本帖最后由 zhj123 于 2010-9-14 12:00 编辑 ]
2010-09-14 11:56
x_wangyue
Rank: 3Rank: 3
等 级:论坛游侠
威 望:1
帖 子:34
专家分:144
注 册:2010-8-30
收藏
得分:5 
#include<iostream>
using namespace std;
int main()
{
    int i=5,j=10,k=20;
    cout<<((i<j)&&(j>k))<<endl;//这里再加一对小()就行了;
    return 0;
}
这是出现错误了,编译器报错see declaration of 'endl',“查看endl的声明”
2010-09-14 12:32
zhj123
Rank: 2
等 级:论坛游民
帖 子:39
专家分:21
注 册:2010-8-31
收藏
得分:0 
回复 4楼 x_wangyue
谢了啊!!
2010-09-15 21:42
快速回复:计算计上出现一些代码,不知道是做什么的,望各位解释哈,谢了
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.023495 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved