Answer to Question #52467 in C++ for Musa

Question #52467
2.1. What is the effect of the following statements? If a statement is invalid, explain why it is invalid. The classes stackADT, stackType, and linkedStackType are as defined in this chapter.
2.1.1. stackADT<int> newStack;
2.1.2. stackType<double> sales(-10);
2.1.3. stackType<string> names;
2.1.4. linkedStackType<int> numStack(50);
1
Expert's answer
2015-05-07T03:15:49-0400
Answer on Question# 52467, Programming, C++2.1. Whatis the effect of the following statements? If a statement is invalid, explain
why it is invalid. The classes stackADT, stackType, and linkedStackType are as
defined in this chapter.
2.1.1.stackADT<int> newStack;
2.1.2.stackType<double> sales(-10);
2.1.3.stackType<string> names;
2.1.4. linkedStackType<int>numStack(50).

Answer:

2.1.1. stackADT<int> newStack – is notvalid since stackADT is abstract class, so we can use only some implementation
of this abstract class.

2.1.2. stackType<double> sales(-10); -create stack size 100, since exist one constructor with parameter, but this
parameter must be positive (otherwise set size to value 100).

2.1.3. stackType<string> names; - createstack of string’s elements, size of stack 100, since class have owner
constructor with default value of elements 100.

2.1.4. linkedStackType<int> numStack(50)– create linked stack with number of integer elements is 50.

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS