c++问题 [Error] 'MA' was not declared in this scope 明明定义了MA了 5
#include<iostream>#include<string>usingnamespacestd;classAccount{public:Account(longi...
#include <iostream>
#include <string>
using namespace std;
class Account
{
public:
Account(long id3, string name3)
{
ID = id3;
name = name3;
}
// private:
protected:
long ID;//账号
string name;//用户名
};
class AliPay:virtual protected Account
{
public:
AliPay(double zamount3, int out3, long ID2, string Name2):Account(ID2, Name2)
{
amount = zamount3;
outlimit = out3;
}
void payadd(double);
// private:
protected:
double amount;//支付宝账户中的金额
int outlimit;//支付宝转账上限,资金转出不得超出账户中金额也不能超出上限
//当转账要求超出上述限制时,自动转出最大允许金额
};
void AliPay::payadd(double addmoney)
{
amount += addmoney;
}
class AliFund:virtual protected Account
{
public:
AliFund(double yamount3, double rate3, int in3, long ID1, string Name1):Account(ID1, Name1)
{
amount = yamount3;
rate = rate3;
inlimit = in3;
}
// private:
protected:
double amount;//余额宝账户中的金额
double rate;//余额宝账户中资金年利率
int inlimit;//余额宝转账下限,资金转入余额宝时不得少于该下限,上不封顶
//当转入资金不足下限金额时,自动忽略该资金转入操作,资金退回
};
class My_Ali:public AliPay, public AliFund
{
public:
My_Ali(long id2, string name2, double zamount2, int out2, double yamount2, double rate2, int in2, int P2, int shold2):
AliPay(zamount2, out2, id2, name2), AliFund(yamount2, rate2, in2, id2, name2), Account(id2, name2)
{
auto_collect_flag = P2;
threshold = shold2;
}
private:
bool auto_collect_flag;//资金自动收集标志
int threshold;//资金自动收集阈值
// protected:
};
int main()
{
long id1;
string name1, P1;
double zamount1, yamount1, rate1;
int out1, in1, shold1, y;
cin >> id1 >> name1 >> zamount1 >> out1 >> yamount1 >> rate1 >> in1 >> P1;
if(P1 == "Y")
{
cin >> shold1;
My_Ali MA(id1, name1, zamount1, out1, yamount1, rate1, in1, 1, shold1);
}
else
My_Ali MA(id1, name1, zamount1, out1, yamount1, rate1, in1, 0, 0);
int x;
double money;
cin >> x >> money;
if(x = 1)
{
cin >> y;
switch(y)
{
case 1:
MA.payadd(money);
}
}
return 0;
} 展开
#include <string>
using namespace std;
class Account
{
public:
Account(long id3, string name3)
{
ID = id3;
name = name3;
}
// private:
protected:
long ID;//账号
string name;//用户名
};
class AliPay:virtual protected Account
{
public:
AliPay(double zamount3, int out3, long ID2, string Name2):Account(ID2, Name2)
{
amount = zamount3;
outlimit = out3;
}
void payadd(double);
// private:
protected:
double amount;//支付宝账户中的金额
int outlimit;//支付宝转账上限,资金转出不得超出账户中金额也不能超出上限
//当转账要求超出上述限制时,自动转出最大允许金额
};
void AliPay::payadd(double addmoney)
{
amount += addmoney;
}
class AliFund:virtual protected Account
{
public:
AliFund(double yamount3, double rate3, int in3, long ID1, string Name1):Account(ID1, Name1)
{
amount = yamount3;
rate = rate3;
inlimit = in3;
}
// private:
protected:
double amount;//余额宝账户中的金额
double rate;//余额宝账户中资金年利率
int inlimit;//余额宝转账下限,资金转入余额宝时不得少于该下限,上不封顶
//当转入资金不足下限金额时,自动忽略该资金转入操作,资金退回
};
class My_Ali:public AliPay, public AliFund
{
public:
My_Ali(long id2, string name2, double zamount2, int out2, double yamount2, double rate2, int in2, int P2, int shold2):
AliPay(zamount2, out2, id2, name2), AliFund(yamount2, rate2, in2, id2, name2), Account(id2, name2)
{
auto_collect_flag = P2;
threshold = shold2;
}
private:
bool auto_collect_flag;//资金自动收集标志
int threshold;//资金自动收集阈值
// protected:
};
int main()
{
long id1;
string name1, P1;
double zamount1, yamount1, rate1;
int out1, in1, shold1, y;
cin >> id1 >> name1 >> zamount1 >> out1 >> yamount1 >> rate1 >> in1 >> P1;
if(P1 == "Y")
{
cin >> shold1;
My_Ali MA(id1, name1, zamount1, out1, yamount1, rate1, in1, 1, shold1);
}
else
My_Ali MA(id1, name1, zamount1, out1, yamount1, rate1, in1, 0, 0);
int x;
double money;
cin >> x >> money;
if(x = 1)
{
cin >> y;
switch(y)
{
case 1:
MA.payadd(money);
}
}
return 0;
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询