This is a problem of solution links: https://pan.baidu.com/s/1c1UtopPy_SH-epr2FxCDlw
Extract the code: the abcd
Problems of CPP file is 5 member attribute is set to private. CPP
# include
# include
using namespace std;
The class Person
{
Public:
//set name
Void elegantly-named setName (string name)
{
M_Name=name;
}
//get name
String getName ()
{
Return m_Name;
}
//get age
Int getAge ()
{
//m_Age=0;//initialize the aged 0
Return m_Age;
}
Void setAge (int age)
{
If (age & lt; 0 | | age & gt; 150)
{
M_Age=0;//output error values, will age is set to 0
Cout & lt; <"You input a wrong age!"return;//out of the current function setAge ()
}
M_Age=age;
}
//set the lover
Void setLover (string lover)
{
M_Lover=lover;
}//* * * * * here abnormal * * * * * *
Private:
String m_Name;//name can be read to write
Int m_Age;//age can be read to write
String m_Lover;//lover just write
};
Int main (void)
{
Person p;
//set the lover
P. etLover (" bridge ");
//cout & lt; <"Lover is:" & lt;system("pause");
return 0;
}
CodePudding user response:
First thank you bosses