#include <iostream>
#include <fstream>
#include <sstream>
using namespace std;
class Three
{
char c;
int i;
public:
Three(char cc = 'a') : c(cc), i(1) { cout<<i++; /*这句话用来显示构造函数调用次数*/}
friend ostream& operator<<(ostream& os, const Three& t)
{
return os << t.c;
}
friend istream& operator>>(istream& is, const Three& t)
{
cout << t.i; /*这句用来显示>>重载函数调用*/
return is >> t.c;
}
};
int main()
{
Three three;
cin >> three; //将这行去掉就没有问题..
cout << three << endl;
return 0;
}
在VC++6.0环境下编译运行结果输出是1212121212121212121212循环,不知为何,请高手帮帮忙..
还有请教一下MinGW Developer Studio 2.05编译器怎么用啊,为什么compile总是灰色的啊??
[此贴子已经被作者于2006-4-6 16:37:10编辑过]