Close Icon
Info
Warning
Danger
 / 
 / 
 / 
Question 1. When it essential that a class have to define

Question : Question 1. When it essential that a class have to define : 867379

Question

1. When is it essential that a class have to define a destructorin C++ class and why?

2. Why should data members of a class be private?

3.

Given an efficient circular array-based queue Q capable ofholding 10 objects. Show the final contents of the array myArray(index from 0 to 9) of the array after the following code isexecuted (you can list the values for myArray[0], myArray[1], ...,myArray[9]):

Queue Q;

for (int k = 1; k ? 7; k++)

                              Q.enqueue(k);

for (int k = 1; k ? 7; k++)

                              Q.enqueue(Q.dequeue());

4.

Assume that Stack is the stack class implemented by a staticarray, with data type is set to int and stack capacity is 5. Givethe contents of the myTop and myArray data members of s after thecode segment is executed, or indicate why an error occurs.

Stack s;

for (int i = 0; i < 2; i++)

               s.push(3*i);

int i = s.top();  

s.pop();

Solution
5 (1 Ratings )

Solved
Computer Science 8 Months Ago 95 Views
This Question has Been Answered!

Unlimited Access

Explore More than 2 Million+
  • Textbook Solutions
  • Flashcards
  • Homework Answers
  • Documents
Signup for Instant Access!

Ask an Expert

Our Experts can answer your tough homework and study questions
154049 Computer Science Questions Answered!
Post a Question