Info
Warning
Danger
/ Homework Answers / Computer Science / Question 1. When it essential that a class have to define

Question

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 2 Months Ago 75 Views
This Question has Been Answered!
Premium Content -

Welcome Back!

ScholarOn has more then 20 Million answers, flashcards & more being added everyday!

or
Forgot?
Login
Don't have an account? Signup

Join ScholarOn

ScholarOn has more then 20 Million answers, flashcards & more being added everyday!

or
Signup
By registering, I agree to the Terms and Privacy Policies
Already have an account? Log in

Verify Your Email

Check your inbox & click on the link to activate your account.

Resend Email
Verification Mail Send Successfully. Please Check Your Email.

Forgot Password

Please enter your registered email to recieve the password reset link.

Send reset link
Already have an account? Log in
Did you know?

ScholarOn has more than 2 Million+ answers, textbook solutions & flashcards. Explore Now!

Let us boost your grade together!