|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
想问一下如何使范闲和范若若的业绩分数每次都不一样(就是让process, rtime, sellings, stime的值每次取不同的随机数)
谢谢大神们!
下面是我的代码:
#include<iostream>
#include<stdlib.h>
using namespace std;
class people
{
protected:
char* name;
char* job;
public:
people(char*name,char*job);
void show();
};
class researcher:public people
{
private:
double process;
double rtime;
double rscore;
public:
researcher(char* name, char*job);
void show();
};
class saler:public people
{
private:
double sellings;
double stime;
double sscore;
public:
saler(char* name, char*job);
void show();
};
void people::show()
{
cout<<"姓名:"<<name<<endl;
cout<<"职位:"<<job<<endl;
}
people::people(char* name,char* job)
{
this->name = name;
this->job = job;
}
void researcher::show()
{
cout<<"姓名:"<<name<<endl;
cout<<"职位:"<<job<<endl;
cout<<"业绩分数:"<<rscore<<endl;
}
researcher::researcher(char* name, char*job):people(name, job)
{
this->process = rand();
this->rtime = rand();
this->rscore = 0.7*process + 0.3*rtime;
}
void saler::show()
{
cout<<"姓名:"<<name<<endl;
cout<<"职位:"<<job<<endl;
cout<<"业绩分数:"<<sscore<<endl;
}
saler::saler(char* name, char* job):people(name, job)
{
this->sellings = rand();
this->stime = rand();
this->sscore = 0.7*sellings + 0.3*stime;
}
int main()
{
saler fan("范闲","销售人员");
fan.show();
researcher fanfemale("范若若","研究者");
fanfemale.show();
return 0;
} |
|