Which of the following are legal access to the class or struct members? Assume each is outside of the class member definitions,

```
struct S class C class D
{ { {
int x; int x; public:
int y; int y; int x;
} private: int y;
S s; int z; private:
}; int z;
C c; };
D d;
```
a)```
s.x
```
b. ```
c.x
```
c. ```
d.x
```
d. ```
c.z
```
e. ```
d.z
```

a) s.x is legal. struct members are public unless otherwise specified.
b) c.x is illegal. class members are private unless otherwise declared public, unless
used in a member function definition. No member function for class C are present.
c) d.x is legal. x is declared to be public within class D
d) c.z is illegal. All members of a class are private unless declared public, unless used
in a member function definition. No member function for class C are present.
e) d.z is illegal, unless this is in a definition of a member of class D. No member
functions are present.

Computer Science & Information Technology

You might also like to view...

Which text direction option displays the text from top to bottom, one character at a time?

A) Rotate all text 270° B) Stacked C) Horizontal D) Piled

Computer Science & Information Technology

The process of saving information to a secondary storage device is referred to as embedding.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology