C++ 技术中心

   :: 首页 :: 联系 ::  :: 管理
  160 Posts :: 0 Stories :: 87 Comments :: 0 Trackbacks

公告

郑重声明:本BLOG所发表的原创文章,作者保留一切权利。必须经过作者本人同意后方可转载,并注名作者(天空)和出处(CppBlog.com)。作者Email:coder@luckcoder.com

留言簿(27)

搜索

  •  

最新随笔

最新评论

评论排行榜

 

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

using namespace std;

class CProduct
{
public:
    CProduct(
int high,int weight, string productName);
private:
    friend ostream
& operator<<(ostream& os,CProduct &product);
private:
    
int m_high;        //
    int m_weight;      //重量
    string m_productName; //产品名称
}
;

 ostream
& operator<<(ostream& os,CProduct &product)
 
{
     os
<<"Product Name:"<<product.m_productName<<" weight:"<<product.m_weight<<" high:"<<product.m_high<<endl;

     
return os;
 }


 inline CProduct::CProduct(
int high,int weight, string productName)
 
{
     
this->m_high = high;
     
this->m_weight = weight;
     
this->m_productName = productName;
 }


int main(int argc,char *argv[])
{
    CProduct product(
175,30,"pig");;
    cout
<<product;

    getch();
    
return 0;
}


posted on 2011-03-04 15:51 C++技术中心 阅读(560) 评论(0)  编辑 收藏 引用 所属分类: C++ 基础

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