GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — CppPrimer/ch08 at master · AnddyWang/CppPrimer

Expand file tree

/

ch08

/
Copy path

Directory actions

More options

More options

Directory actions

More options

More options

Latest commit

 

History

History
History
 
 
/

ch08

/
Copy path

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
README.md
README.md
 
 
ex8_02.cpp
ex8_02.cpp
 
 
ex8_04.cpp
ex8_04.cpp
 
 
ex8_05.cpp
ex8_05.cpp
 
 
ex8_06.cpp
ex8_06.cpp
 
 
ex8_07.cpp
ex8_07.cpp
 
 
ex8_08.cpp
ex8_08.cpp
 
 
ex8_09.cpp
ex8_09.cpp
 
 
ex8_10.cpp
ex8_10.cpp
 
 
ex8_11.cpp
ex8_11.cpp
 
 
ex8_13.cpp
ex8_13.cpp
 
 

README.md

Outline

Chapter 8. The IO Library

Exercise 8.1:

Write a function that takes and returns an istream&. The function should read the stream until it hits end-of-file. The function should print what it reads to the standard output. Reset the stream so that it is valid before returning the stream.

istream& func(istream &is)
{
    std::string buf;
    while (is >> buf)
        std::cout << buf << std::endl;
    is.clear();
    return is;
}

Exercise 8.2

Exercise 8.3:

What causes the following while to terminate?

while (cin >> i) /*  ...    */

putting cin in an error state cause to terminate. such as eofbit, failbit and badbit.

Exercise 8.4

Exercise 8.5

Exercise 8.6

Exercise 8.7

Exercise 8.8

Exercise 8.9

Exercise 8.10

Exercise 8.11

Exercise 8.12:

Why didn’t we use in-class initializers in PersonInfo?

Cause we need a aggregate class here. so it should have no in-class initializers.

Exercise 8.13

Exercise 8.14:

Why did we declare entry and nums as const auto &?

  • cause they are all class type, not the built-in type. so reference more effective.
  • output shouldn't change their values. so we added the const.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.