c++实例研究

从0开始

  C++博客 :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  104 随笔 :: 0 文章 :: 20 评论 :: 0 Trackbacks
#include <cstdlib>
#include 
<iostream>
#include 
<string>
using namespace std;

class Foo
{
public:
    Foo():s(
""){}
    
void show(){cout<<s<<endl;}
    friend istream
& operator>>(istream&,Foo&);
private:
    
string s;
}
;

istream
& operator>>(istream& is,Foo& f)
{
    
is>>f.s;
    
return is;
}


int main()
{
    Foo f;
    cin
>>f;
    f.show();
    system(
"PAUSE");
    
return 0;
}

posted on 2010-05-06 09:46 elprup 阅读(1093) 评论(0)  编辑 收藏 引用 所属分类: c++实例

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理