Warning: foreach() argument must be of type array|object, bool given in /var/www/html/web/app/themes/studypress-core-theme/template-parts/header/mobile-offcanvas.php on line 20

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.)

Short Answer

Expert verified
The result of rewriting two function declarations without the "using namespace std" statement is as follows: ```cpp void input(std::istream& ins); void output(std::ostream& outs) const; ``` By explicitly specifying the standard namespace ('std::') before 'istream' and 'ostream', the dependency on the "using namespace std" statement has been removed.

Step by step solution

01

Identify the objects from the standard "std" namespace

In the given function declarations, "istream" and "ostream" are objects from the standard "std" namespace. These objects should be explicitly referred to using their namespace to remove the dependency on the "using namespace std" statement.
02

Rewrite the function declarations with explicit namespace

The function declarations can be rewritten as: ```cpp void input(std::istream& ins); void output(std::ostream& outs) const; ``` Now, they do not need the "using namespace std" statement because "std::" has been added before "istream" and "ostream" to specify the namespace explicitly.

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

In Self-Test Exercise 7, we saw that you could not add a definition for the following function (to the global namespace): void greeting( ); Can you add a definition for the following function declaration to the global namespace? void greeting(int how_many );

Would the program in Display 12.8 behave any differently if you replaced the using directive using namespace dtimesavitch; with the following using declaration? using dtimesavitch::DigitalTime;

What is the difference between an ADT you define in \(\mathrm{C}_{++}\) and a class you define in \(\mathrm{C}++?\)

include using namespace std; namespace sally { void message( ); } namespace { void message( ); } int ma… # What is the output produced by the following program? #include using namespace std; namespace sally { void message( ); } namespace { void message( ); } int main( ) { { message( ); using sally::message; message( ); } message( ); return 0; } namespace sally { void message( ) { cout << "Hello from Sally.\n"; } } namespace { void message( ) { cout << "Hello from unnamed.\n"; } }

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

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