#include
using namespace std;
class xx
{
public:
xx()
{
quantity=0;
price=0;
}
void total();
static float average();
static void display();
private:
int quantity;
float price;
static double discount;
static float sum;
static int n;
};
void xx:: total()
{
if(quantity>=10)
price=0.98*price;
sum=quantity*price;
n+=quantity;
}float xx::average()
{
return(sum/n);
}
double xx::discount=0.98;
float xx::sum=0;
int xx::n=0;
void xx::display()
{
cout<<"sum:"<<sum<<" "<<"average:"<<xx::average()<<endl;
}
int main()
{
xx t1[3]={xx(5,23.5),
xx(12,24.56),
xx(100,21.5),
}
t1[0].total ();
t1[1].total ();
t1[2].total ();
t1.display();
return 0;
}
问题;C:\Users\dell\Desktop\8.cpp(42) : error C2661: 'xx::xx' : no overloaded function takes 2 parameters