| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 994 人关注过本帖
标题:什么叫做在重载函数在publication中找不到?
取消只看楼主 加入收藏
钟SX
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2013-3-28
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:3 
什么叫做在重载函数在publication中找不到?
#include<iostream.h>
#include<string.h>

class Publication
{
public:
    Pubication( char* name , float price , char* date , char choose );
    bool borrowornot();
    void nature();
    void print();
private:
    char* name;
    float price;
    char* date;
    char choose;
};

Publication::Publication( char* name , float price , char* date , char choose )
{
    this->name = new char [strlen(name)+1];
    strcpy( this->name , name );
    this->price = price;
    this->date = new char[strlen(date)+1];
    strcpy( this->date = date );
    this->choose = choose;
}

bool Publication::borrowornot( char choose )
{
    if( choose == 'Y' )
        return 1;
    else
        return 0;
}

void Publication::print()
{
    cout<<"the book's name is "<< name <<endl;
    cout<<"the book's price is "<< price <<endl;
    cout<<"the book's date of publication is "<< date <<endl;
    if( Publication::borrowornot( char choose ) )
    {
        cout<<"the book has been borrowed , you can't rent it! "<<endl;
    }
    else
    {
        cout<<"the book is available , you can rent it! "<<endl;
    }
}

void main()
{
    char name[100];
    char date[10];
    float price;
    char choose1;
    char choose2;
    cout<<" do you want to get more information?"<<endl;
    cin>>choose1;
    while( choose1=='Y' )
    {
        cout<<"what is the name of the book?"<<endl;
        cin>>name;
        cout<<"when did it public?"<<endl;
        cin>>date;
        cout<<"how much is it?"<<endl;
        cin>>price;
        cout<<"whether the book has been borrowed?(Y/N)"<<endl;
        cin>>choose2;
        Publication book( name , price , date , choose2 );

        book.print();
        cout<<" do you want to get more information?"<<endl;
        cin>>choose1;
    }
}
搜索更多相关主题的帖子: void private include public 
2013-03-29 21:52
钟SX
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2013-3-28
收藏
得分:0 
回复 2楼 yctchxf
我不晓得该怎么改额。。。
2013-03-29 22:00
钟SX
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2013-3-28
收藏
得分:0 
回复 6楼 TonyDeng
这个代码是我自己写的。。。我不知道怎么修改而已。。
2013-03-29 22:23
钟SX
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2013-3-28
收藏
得分:0 
回复 9楼 shmilyflf
嗯嗯,谢谢你,是我太粗心了~
2013-03-30 21:29
快速回复:什么叫做在重载函数在publication中找不到?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.025889 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved