亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費(fèi)注冊 查看新帖 |

Chinaunix

  平臺 論壇 博客 文庫
最近訪問板塊 發(fā)新帖
查看: 1880 | 回復(fù): 1
打印 上一主題 下一主題

[C++] 輸入輸出流重載問題求解 [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報告]
發(fā)表于 2015-04-28 19:43 |只看該作者 |倒序瀏覽
本帖最后由 ANONYMOUS419 于 2015-04-28 20:03 編輯

#include "Input.h"
#include "Output.h"

int main()
{
        Output out;
        Input in;
        int id;
        float math;
        char str[20];

        out << "請輸入學(xué)號:";
        in >> id;
        out << "請輸入姓名和數(shù)學(xué)成績:";
        in >> str >> math;
        out << id << '\t' << str << '\t' << math << endl;
        return 0;
}


#pragma once
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>

class Input
{
public:
        Input & operator>>(int &i)
        {
                scanf("%d", &i);
                return *this;
        }

        Input & operator>>(unsigned int &u)
        {
                scanf("%u", &u);
                return *this;
        }

        Input & operator>>(char &c)
        {
                fflush(stdin);
                c = getchar();
                return *this;
        }

        Input & operator>>(char *str)
        {
                fflush(stdin);
                scanf("%s", str);
                return *this;
        }

        Input & operator >> (float &f)
        {
                scanf("%f", &f);
                return *this;
        }

        Input & operator >> (double &dl)
        {
                scanf("%lf", &dl);
                return *this;
        }
        Input();
        ~Input();
};

#include "Input.h"



Input::Input()
{
}


Input::~Input()
{
}


#pragma once
#define endl "\n"
#include <iostream>

class Output
{
public:
        Output();
        ~Output();
        Output & operator<<(const int i)
        {
                printf("%d", i);
                return *this;
        }

        Output & operator<<(const unsigned int u)
        {
                printf("%u", u);
                return *this;
        }

        Output&operator<<(const char c)
        {
                printf("%c", c);
                return *this;
        }

        Output & operator <<(const char *str)
        {
                printf("%s", str);
                return *this;
        }

        Output & operator <<(const float f)
        {
                printf("%f", f);
                return *this;
        }

        Output & operator <<(const double dl)
        {
                printf("%lf", dl);
                return *this;
        }
};

#include "Output.h"



Output::Output()
{
}


Output::~Output()
{
}





1>------ Build started: Project: HomeWork3, Configuration: Debug Win32 ------
1>  Output.cpp
1>d:\program files (x86)\microsoft visual studio 14.0\vc\include\ostream(992): error C2988: unrecognizable template declaration/definition
1>d:\program files (x86)\microsoft visual studio 14.0\vc\include\ostream(992): error C2059: syntax error: 'string'
1>d:\program files (x86)\microsoft visual studio 14.0\vc\include\ostream(1001): error C2065: '_Elem': undeclared identifier
1>d:\program files (x86)\microsoft visual studio 14.0\vc\include\ostream(1001): error C2065: '_Traits': undeclared identifier
1>d:\program files (x86)\microsoft visual studio 14.0\vc\include\ostream(1001): error C2923: 'std::basic_ostream': '_Elem' is not a valid template type argument for parameter '_Elem'
1>d:\program files (x86)\microsoft visual studio 14.0\vc\include\ostream(1001): error C2923: 'std::basic_ostream': '_Traits' is not a valid template type argument for parameter '_Traits'
1>d:\program files (x86)\microsoft visual studio 14.0\vc\include\ostream(1002): error C2065: '_Elem': undeclared identifier
1>d:\program files (x86)\microsoft visual studio 14.0\vc\include\ostream(1002): error C2065: '_Traits': undeclared identifier
1>d:\program files (x86)\microsoft visual studio 14.0\vc\include\ostream(1002): error C2923: 'std::basic_ostream': '_Elem' is not a valid template type argument for parameter '_Elem'
1>d:\program files (x86)\microsoft visual studio 14.0\vc\include\ostream(1002): error C2923: 'std::basic_ostream': '_Traits' is not a valid template type argument for parameter '_Traits'
1>d:\program files (x86)\microsoft visual studio 14.0\vc\include\ostream(1003): error C2143: syntax error: missing ';' before '{'
1>d:\program files (x86)\microsoft visual studio 14.0\vc\include\ostream(1003): error C2447: '{': missing function header (old-style formal list?)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

論壇徽章:
0
2 [報告]
發(fā)表于 2015-04-28 20:18 |只看該作者
問題已解決,屬于重復(fù)包含頭文件錯誤
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報專區(qū)
中國互聯(lián)網(wǎng)協(xié)會會員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP