Question: If we create a stockDB class which stores variable number of stocks in a dynamic stock array. Complete the minimum stockDB.h class definition such that

  1. If we create a stockDB class which stores variable number of stocks in a dynamic stock array. Complete the minimum stockDB.h class definition such that

stockDB frank(5), obama(700); // frank can have at most 5 stocks, obama 700 max

class stockDB {

  1. (3pt) Write the implementation code (cpp) that supports frank = obama;

  1. (3pt) Further assume that stock has operator< overloaded and there is a global swap(stock&, stock&) function. Complete the following implementation code for stockDB selection sort.

void stockDB::selectionSort() {

  1. Add additional code below to cause a dangling pointer issue.

int * a = new int(5);

int * b = a;

  1. Given the declaration int * d = new int[5]; Check ALL statements that prints out the address of the 2nd elements in d array

    1. cout << d + 1;

    2. cout << d + 4;

    3. cout << &d[1];

    4. cout << &d+4;

    5. cout << d++; // this is a bit tricky

  1. Is the following code correct? If yes, whats the output? If no, whats wrong?

int *p; //Line 1

int *q; //Line 2

p = new int; //Line 3

*p = 43; //Line 4

q = p; //Line 5

*q = 52; //Line 6

delete q; //Line 7

cout << *p << " " << *q << endl; //Line 8

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!