3. (15%) Consider the access of dynamically allocated data structure.
If ptr_s is a pointer to an S_record object and you want to call the show() member function using this pointer, you should use the arrow operator (->). The arrow operator is used in C++ to access members of a structure or a class through a pointer.
Given the context, Statement-2 should be:
This line will call the show() member function of the object that ptr_s points to. If the show() function is implemented such that it displays "Everybody is somebody" on the screen, this statement will achieve the desired output.
如果ptr_s是指向一個S_record對象的指針,並且你想使用這個指針來調用show()成員函數,你應該使用箭頭運算子(->)。箭頭運算子在C++中被用來通過指針訪問結構體或類的成員。
根據上下文,Statement-2應該是:
這行代碼將調用ptr_s所指向的對象的show()成員函數。如果show()函數實現為在屏幕上顯示“Everybody is somebody”,這個語句將實現預期的輸出。