C++新手 error C2593: 'operator <<' is ambiguoe error C2593: 'operator >>' is ambiguous

#include<iostream>
#include<iomanip>
using namespace std;
class Time
{
private:
int h;
int m;
int s;
public:
friend ostream& operator<<(ostream&,Time&);
friend istream& operator>>(istream&,Time&);
Time()
{
h=0;
m=0;
s=0;
}
int geth() const{return h;}
int getm() const{return m;}
int gets() const{return s;}
};

ostream& operator <<(ostream &output,Time &a)
{
output<<setiosflags(ios::fixed)<<setprecision(4)<<a.h+a.m/60+a.h/3600;
return output;
}
istream& operator >>(istream& input,Time& b)
{
input>>b.h>>b.m>>b.s;
return input;
}

第1个回答  2015-05-01
class storehouse{
    int mutex;
    int count;
    int max;
    void save(){
        int changed=false;
                while(changed==false){
                   changed=true;
                   enter(mutex);
                    if(count<max)count++;
                    else changed=false;
                leave(mutex);
                sleep(0);
            }
    }
    void sell(){
       int changed=false;
               while(changed==false){
                  changed=true;
                  enter(mutex);
                   if(count>0)count--;
                   else changed=false;
               leave(mutex);
               sleep(0);
           }
    }
 
}
class Producer{
    produect(storehouse& store){
        store.save();
    }
}
class consumer{
    consum(storehouse& store){
        store.sell();
    }
 
}
 
int main(){
    storehouse store1;
    vector<Producer> products;
    vector<consumer> consums;
    vector<std:thread> allthread;
  while(products.size()||consums.size()){
    if(products.size()) allthread.push_back(std::thread t(&Producer,products.pop_back()));
    if(consums.size())allthread.push_back(std::thread(&consums.sell(),consums.pop_back()));
}
 for(auto athread:allthread)athread.join();
    
}

本回答被网友采纳
第2个回答  2015-04-29
编译时正常的啊,我是用vs编译的本回答被提问者采纳
第3个回答  2015-04-30
dev-c++语法检查正常。0错误0警告。
相似回答