关于cin / cout重载的简单问题4

时间:2013-07-18 14:09:41

标签: c++ visual-c++ iostream

#include <iostream>
#include <math.h>
#include <conio.h>

using namespace std;


class hugeint 
{
public:
    int size;
    int number[100];


    friend istream& operator>>(istream&,hugeint&);
    friend ostream& operator<<(ostream&,hugeint&);
};


istream& operator>>(istream& in,hugeint& c)
{
    // code not shown
    return in;
}


ostream& operator<<(ostream& out,hugeint& c)
{
    return out;
}


void main()
{
    system( "color 70" ); 

    hugeint o;
    hugeint y;
    hugeint z;

    cin >> o;
    cout<<"now y "<<endl;
    cin>>y;
}

编译器抱怨operator >>含糊不清......我该怎么办?

2 个答案:

答案 0 :(得分:1)

不,the code compiles

但请注意,我还删除了您的无关和非C ++标头,并修复了错误的main返回类型。

答案 1 :(得分:-1)

尝试将operator<<operator>>函数放入std命名空间