133k views
1 vote
Class members are accessed via the ____(1)_____ operator in conjunction with the name of an object of the class, or via the ___(2)_____ operator in conjunction with a pointer to an object of the class.

1 Answer

4 votes

Answer:

1.ClassName and . operator

2. ClassName and [] operator

Step-by-step explanation:

There are two ways to get the members of a class first one is by using dot(.) operator.

Example : with assumption that person is a class object and age is the member in it we can use it as:

person.age

Second way is to use [] operator with member as a string in it which is used by the compiler as key to get its value.

Example : person["age"]

User Keith G
by
5.3k points