谢过先,呵呵
这个是VC++  MSDN里提供的例子:
//Sample.cpp
// Compiler Options : /GX
//#define WORKAROUND  
//Uncomment this line to workaround
#include<iostream>
using namespace std;
#ifdef WORKAROUND
std::ostream& operator<<(std::ostream& os, __int64 i )
{
  char buf[20];
  sprintf(buf,"%I64d", i );
  os << buf;
  return os;
}
 #endif
int main()
{
 
__int64  i64;
  cout << i64 ;//这是提示错误的地方,
 
//这是编译提示的错误D:\工程\VC_workspace\text\sample.cpp(23) : error C2593: 'operator <<' is ambiguous
   return 0;
}
自己的程序是这样的:
// Demonstrate the multithreaded garbage collector. 
#include <iostream> 
#include <new> 
#include "gcthrd.h" 
using namespace std; 
// A simple class for load testing GCPtr. 
class LoadTest
{ 
 
//int a, b; 
 public: 
  double n[100000]; // just to take-up memory 
  double val; 
  int a, b;
  LoadTest() { a = b = 0; } 
   LoadTest(int x, int y) 
   { 
     a = x; 
     b = y; 
     val = 0.0; 
   } 
 friend ostream &operator<<(ostream &strm, LoadTest &obj); 
}; 
// Create an insertor for LoadTest. 
ostream &operator<<(ostream &strm, LoadTest &obj) 
{ 
   strm << "(" << obj.a << " " << obj.b << ")"; 
  return strm; 
} 
 int main() 
{ 
  
 GCPtr<LoadTest> mp; 
  
 int i; 
  
 for(i = 1; i < 2000; i++) { 
  
 try { 
        mp = new LoadTest(i, i); 
        if(!(i%100)) 
          cout <<
"gclist contains " << mp.gclistSize() << " entries.\n"; 
      }
  catch(bad_alloc xa)
  { 
    
// For most users, this exception won't 
     // ever occur. 
     cout << "Last object: " << *mp << endl; //这是出错的地方
    //  编译提示的错误:D:\工程\VC_workspace\GCPtr\main.cpp(46) : error C2593:'operator <<' is ambiguous
   
cout << "Length of gclist: " << mp.gclistSize() << endl; 
    } 
  } 
 return 0; 
}
我在想,是不是编译环境的问题,也不知道该如何去设置。
[此贴子已经被作者于2006-3-9 16:17:12编辑过]