I have a pointer, nodePtr to a node that is a struct in a linked list. I want to access the member named data. I do this using the expression

a) nodePtr.data
b) nodePtr->data
c) *nodePtr.data
d) (*nodePtr).data
e) data is private, you can’t access data under any circumstances.


b) nodePtr->data , and e) data is private, you can’t access data under any circumstances.

a) attempts to access a member through a something that is not a class or a struct. nodePtr is pointer, not a struct or class. Part c) gets into precedence trouble. The postfix dot operator binds more closely than the prefix * operator, so we are attempting to access a member in a pointer rather than a struct. Part e) is wrong. The pointer variable nodePtr points to a struct, so access is no problem.

Computer Science & Information Technology

You might also like to view...

Write Java statements to display the size of the resulting ArrayList from question 5 above.

What will be an ideal response?

Computer Science & Information Technology

Warp, distort, and transform effects are all capable of producing cool and interesting results.

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

Computer Science & Information Technology

Which of the following statements about JPA database transaction processing is false?

a. Transaction processing enables a program that interacts with a database to treat a set of operations as a single operation. Such an operation also is known as an atomic operation or a transaction. b. At the end of a transaction, a decision can be made either to commit the transaction or roll back the transaction. c. Committing a transaction finalizes the database operation(s); all insertions, updates and deletions performed as part of the transaction cannot be reversed. d. Rolling back the transaction leaves the database in its state prior to the database operation. This is useful when a portion of a transaction fails to complete properly.

Computer Science & Information Technology

The set accessor enables you to .

a) provide range checking b) modify data c) provide data validation d) All of the above.

Computer Science & Information Technology