Home / Expert Answers / Accounting / question-3-discuss-the-concept-of-pointers-arrays-and-dynamically-allocated-memory-by-answering-pa789

(Solved): Question 3 Discuss the concept of pointers, arrays and dynamically allocated memory by answering ...



Question 3
Discuss the concept of pointers, arrays and dynamically allocated memory by
answering the following questions.
(a)

The class MyBook has two data members:
An integer, numofBooks, represents the mimber of books.
A dynamic location large enoug

Question 3 Discuss the concept of pointers, arrays and dynamically allocated memory by answering the following questions. (a) Assume the following definition and initialisation: int mtdArray[7] = {6, 8, , 1, 7, 5, 3}; What output does each of the following statements produce? Explain your answer (6) (1) cout << mtdArray[3] << endl; (11 cout << mtdArray[2] + mtdArray[4] << endl; (11) cout << mtdArray[mtdArray[4] - mtdArray[3]] << endl; (7 marks) Write C++ statements to carry out the following tasks: Declare a variable c and assign it the character 'M'; Declare a variable pChar as a char pointer; Make pChar point to the location where c is Increment c by 1 and store the result in the location where pChar is pointing What is the ouput when the statement below is executed? cout << *pChar << endl; (6 marks) The class MyBook has two data members: An integer, numofBooks, represents the mimber of books. A dynamic location large enough to store the titles of a collection of books. The size of the collection is determined by numoiBooks. The location is referenced by the pointer string* tities. (1) Define MyBook class with the appropriate data members, constructor and destructor (9 marks) (11) Write a main function to demonstrate how a Mybook instance can be created (3 marks)


We have an Answer from Expert

View Expert Answer

Expert Answer


Quection -3 int mtsArray[7]={6,8,0,1,7,5,3}; according to language index start from 0 so in t
We have an Answer from Expert

Buy This Answer $5

Place Order