Home > Back-end >  Would you please tell me why, in the aa object the add () member function can direct access to the b
Would you please tell me why, in the aa object the add () member function can direct access to the b

Time:11-29

#include
using namespace std;
Class A
{
Public:
Int pubcc_i;
(A);
Void the add ();
Private:
Int pri_i;
Int pri_j;

Void PPC (A tk);

};

A: : (A) {
Pri_i=20.
Pri_j=30;

}



Void A: : add () {
Cout<& lt;" The current object is="& lt; & lt; This<& lt; Endl;//make sure the current object address

A, bb.
Cout<& lt;" Bb this="& lt; & lt; & Bb<& lt; Endl;//make sure bb address

Cout<& lt; Bb. Pri_i + bb. Pri_j & lt; & lt; Endl;//here don't understand why in aa object can be accessed in the bb object of private data and the former two cout also can see the current do
//is article 3 cout in aa object add () to see that aa and bb are two independent object but cout<& lt; Bb. Pri_i + bb. Pri_j & lt; & lt; Endl;
//how can work
}

Int main ()
{
A, aa.
Cout<& lt;" Aa this is "& lt; & lt; & Aa<& lt; Endl;//here to confirm under aa object address
Aa. The add ();
return 0;
}

CodePudding user response:

So-called is protective against a type, rather than an object for specific

CodePudding user response:

Positive solution on the ground floor (please enter a string length is at least 6)

CodePudding user response:

So-called is protective against a type, rather than an object for specific
What's the meaning of this sentence,,,,

CodePudding user response:

reference xiexiejohn reply: 3/f
so-called is aimed at a kind of protective, rather than an object for specific
What's the meaning of this sentence,,,,

To understand this sentence what mean, must first understand what type, what is a concrete object, such as int a; This sentence is an int type, is a specific object,
  • Related