Suppose that you are defining an ADT class and that you then use this class in a program. You want to separate the class and program parts into separate files as described in this chapter. Specify whether each of the following should be placed in the interface file, implementation file, or application file: a. The class definition b. The declaration for a function that is to serve as an ADT operation, but that is neither a member nor a friend of the class c. The declaration for an overloaded operator that is to serve as an ADT operation, but that is neither a member nor a friend of the class d. The definition for a function that is to serve as an ADT operation, but that is neither a member nor a friend of the class e. The definition for a friend function that is to serve as an ADT operation f. The definition for a member function g. The definition for an overloaded operator that is to serve as an ADT operation, but that is neither a member nor a friend of the class h. The definition for an overloaded operator that is to serve as an ADT operation and that is a friend of the class i. The main part of your program

Short Answer

Expert verified
Element: - a. The class definition --> Interface file - b. The declaration for a function that is to serve as an ADT operation, but that is neither a member nor a friend of the class --> Interface file - c. The declaration for an overloaded operator that is to serve as an ADT operation, but that is neither a member nor a friend of the class --> Interface file - d. The definition for a function that is to serve as an ADT operation, but that is neither a member nor a friend of the class -> Implementation file - e. The definition for a friend function that is to serve as an ADT operation --> Implementation file - f. The definition for a member function --> Implementation file - g. The definition for an overloaded operator that is to serve as an ADT operation, but that is neither a member nor a friend of the class --> Implementation file - h. The definition for an overloaded operator that is to serve as an ADT operation and that is a friend of the class --> Implementation file - i. The main part of your program --> Application file

Step by step solution

01

a. The class definition

The class definition should be placed in the interface file. This is because the interface file contains the declarations of the class and its member functions, which are essential for the abstraction of the ADT.
02

b. The declaration for a function that is to serve as an ADT operation, but that is neither a member nor a friend of the class

This function declaration should be placed in the interface file as well. Since it's an ADT operation but not a member or friend function, it should be accessible to the users without having to delve into the implementation.
03

c. The declaration for an overloaded operator that is to serve as an ADT operation, but that is neither a member nor a friend of the class

The declaration for this overloaded operator should also be placed in the interface file since it's going to serve as an ADT operation and will be used by the users.
04

d. The definition for a function that is to serve as an ADT operation, but that is neither a member nor a friend of the class

The definition of this function should be placed in the implementation file. This file contains the definitions of the functions that implement the behavior of the ADT, without revealing their specifics to the users.
05

e. The definition for a friend function that is to serve as an ADT operation

The definition for this friend function should be placed in the implementation file. Even though it's a friend function, it's still part of the ADT behavior implementation.
06

f. The definition for a member function

The definition for a member function should be placed in the implementation file. Member functions are part of the ADT behavior implementation, and their definitions are separated from the class declaration to maintain abstraction.
07

g. The definition for an overloaded operator that is to serve as an ADT operation, but that is neither a member nor a friend of the class

The definition for this overloaded operator should be placed in the implementation file, since it belongs to the implementation part of the ADT behavior.
08

h. The definition for an overloaded operator that is to serve as an ADT operation and that is a friend of the class

The definition for this overloaded operator should be placed in the implementation file. Despite it being a friend function, it's still part of the ADT behavior implementation.
09

i. The main part of your program

The main part of the program should be placed in the application file. This file is where the ADT class is utilized to perform specific tasks and is separate from the interface and implementation files to maintain a clear separation of concerns.

Unlock Step-by-Step Solutions & Ace Your Exams!

  • Full Textbook Solutions

    Get detailed explanations and key concepts

  • Unlimited Al creation

    Al flashcards, explanations, exams and more...

  • Ads-free access

    To over 500 millions flashcards

  • Money-back guarantee

    We refund you if you fail your exam.

Over 30 million students worldwide already upgrade their learning with Vaia!

One App. One Place for Learning.

All the tools & learning materials you need for study success - in one app.

Get started for free

Most popular questions from this chapter

Suppose you want to change the implementation of the class DigitalTime given in Displays 12.1 and \(12.2 .\) Specifically, you want to change the way the time is recorded. Instead of using the two private variables hour and minute, you want to use a single (private) int variable, which will be called minutes. In this new implementation the private variable minutes will record the time as the number of minutes since the time \(0: 00(\text { that is, since midnight }) .\) So 1: 30 is recorded as 90 minutes, since it is 90 minutes past midnight. Describe how you need to change the interface and implementation files shown in Displays 12.1 and 12.2 You need not write out the files in their entirety; just indicate what items you need to change and how, in a very general way, you would change them.

Consider the program shown in Display \(12.5 .\) Could we use the name greeting in place of big_greeting?

Suppose you define a class in separate files and use the class in a program. Now suppose you change the class implementation file. Which of the following files, if any, need to be recompiled: the interface file, the implementation file, or the application file?

Write the function declaration for a void function named wow. The function wow has two parameters, the first of type speed as defined in the speedway namespace and the second of type speed as defined in the indy500 namespace.

Consider the following function declarations from the definition of the class Money in Display 11.4. void input(istream& ins); void output(ostream& outs) const; Rewrite these function declarations so that they do not need to be preceded by using namespace std; (You do not need to look back at Display 11.4 to do this.)

See all solutions

Recommended explanations on Computer Science Textbooks

View all explanations

What do you think about this solution?

We value your feedback to improve our textbook solutions.

Study anywhere. Anytime. Across all devices.

Sign-up for free