| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 485 人关注过本帖
标题:求各位指点错误:商店销售一产品,一次购十件打折9.8,价格由售货员自定,求 ...
只看楼主 加入收藏
唐兵
Rank: 2
来 自:四川泸州合江
等 级:论坛游民
帖 子:150
专家分:12
注 册:2012-12-1
结帖率:82.05%
收藏
已结贴  问题点数:20 回复次数:3 
求各位指点错误:商店销售一产品,一次购十件打折9.8,价格由售货员自定,求该商店每件商品的均价
求各位指点错误:商店销售一产品,一次购十件打折9.8,价格由售货员自定,求该商店每件商品的均价

#include <iostream>
using namespace std;
class product
{public:
    product(int n,int q,int p ):num(n),quantity(q),price(p){};
 static int display();
private:
    int num;
    int quantity;
    int price;
    static int sum;
    static int fcount;
};   
int product:: display()
    {   
    int cout=0,i=0;
        for(i=0;i<3;i++)
    {
        cout<<"please input num,quantity and the price"<<endl;
        cin>>nu[i].num>>endl>>nu[i].quantity>>endl>>nu[i].price>>endl;
        if (n[i].quantity>10) price=0.98*price;
            sum+=price;
            count++;
            return sum;
    }   
int product::sum=0;
int product::count=0;
int main()
{
    int x,y;
    product nu[3]={
    product (01,1,15),
    product    (02,3,10),
    product(03,20,20)};
    x=display();
    y=average();
    cout<<y;
    return 0;
}
搜索更多相关主题的帖子: static 产品 quantity private display 
2013-03-30 11:04
yuccn
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:何方
等 级:版主
威 望:167
帖 子:6814
专家分:42393
注 册:2010-12-16
收藏
得分:14 
1
int product:: display() 函数没有又括号

2
 main中 x=display();访问类函数要标明前序的,product:: display

3
int product:: display() 中的nu 在哪里定义了?n在哪里定于了?

建议楼主那边基础的书籍来先看看吧

我行我乐
公众号:逻辑客栈
我的博客:
https://blog.yuccn. net
2013-03-30 19:19
唐兵
Rank: 2
来 自:四川泸州合江
等 级:论坛游民
帖 子:150
专家分:12
注 册:2012-12-1
收藏
得分:0 
回复 2楼 yuccn
1
int product:: display() 函数没有又括号
:哪儿,不太懂
3
int product:: display() 中的nu 在哪里定义了?n在哪里定于了?
:定义的是数组nu[3]啊,这样不可以吗?

一个人如果不比自己一把,你永远不知道自己究竟有多厉害
2013-03-30 20:23
唐兵
Rank: 2
来 自:四川泸州合江
等 级:论坛游民
帖 子:150
专家分:12
注 册:2012-12-1
收藏
得分:0 
#include <iostream>
using namespace std;
class product
{public:
    product(int n,int q,int p ):num(n),quantity(q),price(p){};
    int display();
private:
    int num;
    int quantity;
    int price;
    static int sum;
    static int n;
};   
int product:: display()
    {   
    int cout=0,i=0,n=0;
        
        for(i=0;i<3;i++)
        {
            cout<<"please input num,quantity and the price"<<endl;//错误'<<' : illegal, right operand has type 'char [40]'
            cin>>nu[i].num>>endl>>nu[i].quantity>>endl>>nu[i].price>>endl;//错误'nu' : undeclared identifier。
        if (quantity>10) price=0.98*price;
            sum+=price;
            n=n+quantity;}
        cout<<(sum/n);//警告<<' : operator has no effect; expected operator with side-effect
        return 0;
    }   
int product::sum=0;
int product::n=0;
int main()
{
    int x,y;
    product nu[3]={
    product (01,1,15),
    product (02,3,10),
    product (03,20,20)};
    int display();
   
    return 0;
}

一个人如果不比自己一把,你永远不知道自己究竟有多厉害
2013-03-30 20:59
快速回复:求各位指点错误:商店销售一产品,一次购十件打折9.8,价格由售货员自 ...
数据加载中...
 
   



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

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