Q2.1 According to C++ recommended practice, in which section of the class should we find the declarations of int stack [MAX_SIZE]; and int size; ? O Public O Private Q2.2 When we put the method body (e.g. { return size == 0; } for isEmpty inside the class declaration (i.e. in the IntStack.h file) that makes isEmpty a special type of member function (three word phrase with initials IMF). What does IMF stand for? Enter your answer here Q2.3 What is one thing that is different about IMF from the perspective of how they are treated by the compiler? Enter your answer here

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter18: Stacks And Queues
Section: Chapter Questions
Problem 16PE: The implementation of a queue in an array, as given in this chapter, uses the variable count to...
icon
Related questions
Question
Q2.1
According to C++ recommended practice, in which section of the class should we find the
declarations of int stack [MAX_SIZE]; and int size; ?
Public
Private
Q2.2
When we put the method body (e.g. { return size == 0; } for isEmpty inside the
class declaration (i.e. in the IntStack.h file) that makes isEmpty a special type of
member function (three word phrase with initials IMF). What does IMF stand for?
Enter your answer here
Q2.3
What is one thing that is different about IMF from the perspective of how they are treated
by the compiler?
Enter your answer here
Transcribed Image Text:Q2.1 According to C++ recommended practice, in which section of the class should we find the declarations of int stack [MAX_SIZE]; and int size; ? Public Private Q2.2 When we put the method body (e.g. { return size == 0; } for isEmpty inside the class declaration (i.e. in the IntStack.h file) that makes isEmpty a special type of member function (three word phrase with initials IMF). What does IMF stand for? Enter your answer here Q2.3 What is one thing that is different about IMF from the perspective of how they are treated by the compiler? Enter your answer here
Suppose we implement a class for a stack of integers, called IntStack. Our implementation
uses a variable int stack [MAX_SIZE] and a variable int size. The constant MAX_SIZE may
be declared as const int MAX_SIZE=100, for example. I will have methods push, pop,
isEmpty and since our implementation has a max size, isFull.
If we declare a method with the function prototype bool isEmpty() const, I have the option
of putting the function body either in a separate IntStack.cpp file, or directly inside the
IntStack.h file like this:
// If this is in the header file, it should be declared
// `inline`. Otherwise, we get multiple definitions!
bool isEmpty() const { return size
==
0; }
Transcribed Image Text:Suppose we implement a class for a stack of integers, called IntStack. Our implementation uses a variable int stack [MAX_SIZE] and a variable int size. The constant MAX_SIZE may be declared as const int MAX_SIZE=100, for example. I will have methods push, pop, isEmpty and since our implementation has a max size, isFull. If we declare a method with the function prototype bool isEmpty() const, I have the option of putting the function body either in a separate IntStack.cpp file, or directly inside the IntStack.h file like this: // If this is in the header file, it should be declared // `inline`. Otherwise, we get multiple definitions! bool isEmpty() const { return size == 0; }
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Linked List Representation
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning