| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 329 人关注过本帖
标题:
只看楼主 加入收藏
wuyushuai521
Rank: 2
等 级:论坛游民
帖 子:80
专家分:47
注 册:2012-10-9
结帖率:100%
收藏
已结贴  问题点数:10 回复次数:5 
各位:
   调用计算机系统命令行中的c++编译器或链接器的命令是?
                           谢谢
搜索更多相关主题的帖子: 编译器 计算机系统 
2012-10-23 20:20
wp231957
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:神界
等 级:贵宾
威 望:423
帖 子:13688
专家分:53332
注 册:2012-10-18
收藏
得分:2 
cl。exe  make。exe

??

DO IT YOURSELF !
2012-10-23 20:23
pangding
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
来 自:北京
等 级:贵宾
威 望:94
帖 子:6784
专家分:16751
注 册:2008-12-20
收藏
得分:4 
vs的话,好像是楼上说的这两个。

调用不同的编译器命令肯定不一样呀,楼主不能这么笼统地问。而已这个问题的标题和内容有点不符吧,楼主可以自己改改。
2012-10-23 23:32
wuyushuai521
Rank: 2
等 级:论坛游民
帖 子:80
专家分:47
注 册:2012-10-9
收藏
得分:0 
在下目前正在学习类,然后在章未有一道针对类的编程题,主要是说:可以把类的定义、说明不放在main函数中,所以请教各位能不能给一道关于类的小程序,然后把具体的操作步骤也说一下。谢谢了!      
2012-10-24 19:43
pangding
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
来 自:北京
等 级:贵宾
威 望:94
帖 子:6784
专家分:16751
注 册:2008-12-20
收藏
得分:4 
以下是引用wuyushuai521在2012-10-24 19:43:11的发言:

在下目前正在学习类,然后在章未有一道针对类的编程题,主要是说:可以把类的定义、说明不放在main函数中,所以请教各位能不能给一道关于类的小程序,然后把具体的操作步骤也说一下。谢谢了!      

一般都不放在 main 函数中吧……
2012-10-25 11:49
wuyushuai521
Rank: 2
等 级:论坛游民
帖 子:80
专家分:47
注 册:2012-10-9
收藏
得分:0 
是的。在下就是不明白如何应用类。下面是一个关于类的编程练习题,我放上来。让版主和各位同仁看看,如何操作?谢谢
class cashregister
{
public:
    int getcurrentbalance() const;
    void acceptamount(int amount);
    cashregister(int cashin=500);
private:
    int cashonhand;
};

class dispensertype
{
public:
    int getnoofitems() const;
    int getcost() const;
    void makesale();
    dispensertype(int setnoofitems=50, int setcost=50);
private:
    int numberofitems;
    int cost;
};

#include <iostream>
#include "cashregister.h"


using namespace std;

int cashregister::getcurrentbalance() const
{
    return cashonhand;
}

void cashregister::acceptamount(int amount)
{
    cashonhand+=amount;
}

cashregister::cashregister(int cashin)
{
    if(cashin>=0)
        cashonhand=cashin;
    else
        cashonhand=500;
}

#include <iostream>
#include "dispensertype.h"

using namespace std;

int dispensertype::getnoofitems() const
{
    return numberofitems;
}

int dispensertype::getcost() const
{
    return cost;
}
void dispensertype::makesale()
{
    numberofitems--;
}
dispensertype::dispensertype(int setnoofitems, int setcost)
{
    if(setnoofitems>=0)
        numberofitems=setnoofitems;
    else
        numberofitems=50;

    if(setcost>=0)
        cost=setcost;
    else
        cost=50;
}


#include <iostream>
#include "cashregister.h"
#include "dispensertype.h"

using namespace std;

void showselection();
void sellproduct(dispensertype& produce, cashregister& pcounter);

int main()
{
    cashregister counter;
    dispensertype candy(100,50);
    dispensertype chips(100,65);
    dispensertype gum(75,45);
    dispensertype cookies(100, 85);


    int choice;

    showselection();

    cin>>choice;

    while(choice!=9)
    {
        switch(choice)
        {
        case 1: sellproduct(candy, counter);break;
        case 2: sellproduct(chips, counter);break;
        case 3: sellproduct(gum, counter);break;
        case 4: sellproduct(cookies, counter);break;
        default: cout<<"invalid selection."<<endl;
        }
        showselection();
        cin>>choice;
    }
    return 0;
}

void showselection()
{
    cout<<"***welcome to shelly's candy shop***"<<endl;
    cout<<"TO select an item, enter"<<endl;
    cout<<"1 for candy"<<endl;
    cout<<"2 for chips"<<endl;
    cout<<"3 for gum"<<endl;
    cout<<"4 for cookies"<<endl;
    cout<<"9 to exit"<<endl;
}

void sellproduct(dispensertype& product, cashregister& pcounter)
{
    int amount1;
    int amount2;

    if(product.getnoofitems()>0)
    {
        cout<<"please deposit "<<product.getcost()<<"cents"<<endl;
        cin>>amount1;

        if(amount1<product.getcost())
        {
            cout<<"please deposit another"<<product.getcost()-amount1<<"cents"<<endl;
            cin>>amount2;
            amount1+=amount2;
        }

        if(amount1>=product.getcost())
        {
            pcounter.acceptamount(amount1);
            product.makesale();
            cout<<"collect your item at the bottom and enjoy."<<endl;
        }
        else
            cout<<"the amount is not enough."<<"collect what you deposited."<<endl;
        cout<<"*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-"<<endl;
        cout<<endl;
    }
    else
        cout<<"sorry, this item is sold out"<<endl;
}



2012-10-25 12:58
快速回复:
数据加载中...
 
   



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

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