using namespace std;
The class First
{
Friend int func (First f)//why change (First & amp; F) after not to drop with a copy constructor??????? (as shown in figure 2), do not add & amp; The answer is shown in figure a,
{
F.d ata *=2;
Return f.d ata.
}
Private:
The int data;
Public:
First (int d)
{
data=https://bbs.csdn.net/topics/d;
}
The First (First & amp; F)
{
data=https://bbs.csdn.net/topics/f.data;
Cout<" Copy constructor \ n ";
}
Void setData (int d)
{
data=https://bbs.csdn.net/topics/d;
}
Const int getData ()
{
return data;
}
};
Int main ()
{
The First formula one (1);
Cout<" Before: \ n ";
Cout<" F1. Data="https://bbs.csdn.net/topics/
Cout<" F1. Data="https://bbs.csdn.net/topics/
}
CodePudding user response:
Image upload is wrong, just don't add & amp; The answer as shown in figure a, added & amp; The answer is shown in figure 4CodePudding user response:
Add & amp; What is the reference, please baidu is a c + + referenceCodePudding user response: