Question: This is an extract from the code fragment: 6 : class A 7 : { 8 : private: 9 : int x; 1 0 :

This is an extract from the code fragment:
6: class A
7: {
8: private:
9: int x;
10: protected:
11: int getX();
12: public:
13: void setX();
14: };
15:
16: int A::getX()
17: {
18: return x;
19: }
20:
21: void A::setX()
22: {
23: x=10;
24: }
The reason why line 18 is a valid access in this code fragment, is because the variable x is a private data member of the class A. Private data members can only be accessed by other member functions and operators of the class A. getX() is a member function of class A and therefore line 18 is a valid access.
Select one:
True

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!