注册 登录
编程论坛 C++教室

帮忙解决问题

晓宁 发布于 2011-09-26 21:58, 345 次点击
#include<iostream>
using namespace std;

class Customer
{
protected:
    char Customer_name[20];
    int IC_number;
public:
    void get()
    {
        cout<<"\nEnter Customer Name: ";
         cin>>Customer_name;
         cout<<"\nEnter Customer IC: ";
         cin>>IC_number;
    }
};

class Prize : private Customer
{
private:
    double pa;
public:
    void accept();
    void display();
};

void Prize :: accept()
{
    get();
    cout<<"\nEnter the purchase amount:";
    cin>>pa;
}

void Prize :: display()
{
    if(pa > 5000)
        cout<<"\nThe Customer will get a plate set as a free gift."<<endl;
else
    if(pa = 5000) || (pa < 5000) && (pa > 3000)
        cout<<"\nThe free gift is a limited edition container."<<endl;
else
    if(pa = 3000) || (pa < 3000)
        cout<<"\nNo free gift."<<endl;

}

void main()
{
    Prize obj;
    obj.accept();
    obj.display();
}
1 回复
#2
czsbc2011-09-26 22:47
if(pa = 5000) || (pa < 5000) && (pa > 3000)
if(pa = 3000) || (pa < 3000)
 发现掉俩括号。
1