//先攢生亂數規則 亂數種子
//產生亂數值
//取1-49之間的整數
//怎麼取?
//求餘數的方式 %49 就可以得到0-48之間的整數
// +1之後就是1-49
星期四, 6月 04, 2015
朋友類別函數:需做修改
#include
using namespace std;
class classfriend
{
public:
void setup(int power);};
class car
{
private:
int num;
double gas;
};
void classfriend::setup(int power)
{int motive=power;
car March;
March.num=200;
March.gas=20.0;
cout<<"--March--\n"<<"傳入為"<cout<<"Gas為"<}
int main( )
{ classfriend pow;
pow.setup(300);
return 0; }
using namespace std;
class classfriend
{
public:
void setup(int power);};
class car
{
private:
int num;
double gas;
};
void classfriend::setup(int power)
{int motive=power;
car March;
March.num=200;
March.gas=20.0;
cout<<"--March--\n"<<"傳入為"<
int main( )
{ classfriend pow;
pow.setup(300);
return 0; }
朋友類別:需做修改
#include
using namespace std;
class car{
private:
int num;
double gas;
};
class runcar:public car{
public:
/*
runcar()
{
num=0;
gas=10;
}
*/
};
class classfriend
{public:
static int power;
static void setup(int power);
};
int classfriend::power=1;
class runclassfriend:public classfriend{
{
public:;
/*
runclassfriend()
{
num=0;
gas=10;
}
*/
};
void classfriend::setup(int power)
{
int motive=power;
car march;
march.num=200;
march.gas=20.0;
runcar march1;
march1.num=2000;
march1.gas=40.0;
cout<<"--march--"<<"傳入為"<cout<<"--march1--"<<"號碼為"<cout<<"Gas為"<}
int main( )
{
classfriend::setup(300);
runclassfriend::setup(3000); //朋友的兒子?
car march;
classfriend classfriend1;
classfriend1.setup(20);
march.num=200;
march.gas=20.0;
runcar march1;
march1.num=2000;
march1.gas=40.0;
cout<<"--march--"<<"號碼為"<cout<<"--march1--"<<"號碼為"<return 0;
}
using namespace std;
class car{
private:
int num;
double gas;
};
class runcar:public car{
public:
/*
runcar()
{
num=0;
gas=10;
}
*/
};
class classfriend
{public:
static int power;
static void setup(int power);
};
int classfriend::power=1;
class runclassfriend:public classfriend{
{
public:;
/*
runclassfriend()
{
num=0;
gas=10;
}
*/
};
void classfriend::setup(int power)
{
int motive=power;
car march;
march.num=200;
march.gas=20.0;
runcar march1;
march1.num=2000;
march1.gas=40.0;
cout<<"--march--"<<"傳入為"<
int main( )
{
classfriend::setup(300);
runclassfriend::setup(3000); //朋友的兒子?
car march;
classfriend classfriend1;
classfriend1.setup(20);
march.num=200;
march.gas=20.0;
runcar march1;
march1.num=2000;
march1.gas=40.0;
cout<<"--march--"<<"號碼為"<
}