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/ch18 at master · AnddyWang/CppPrimer

Expand file tree

/

ch18

/
Copy path

Directory actions

More options

More options

Directory actions

More options

More options

Latest commit

 

History

History
History
 
 
/

ch18

/
Copy path

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
ex18.1.2.3
ex18.1.2.3
 
 
ex18.12.13.14
ex18.12.13.14
 
 
ex18.15.16.17
ex18.15.16.17
 
 
README.md
README.md
 
 

README.md

##Exercise 18.1

What is the type of the exception object in the following throws?

(a)range_error r("error"); throw r; (b)exception *p = &r; throw *P;

What would happen if the throw in (b) were written as throw p?

The type of the exception object in (a) is range_error which is used to report range errors in internal computations.
The type of the exception object in (b) is exception.
If the "throw" in (b) were written as "throw p", there will be a runtime error.

##Exercise 18.2

Explain what happens if an exception occurs at the indicated point:

void exercise(int *b, int *e)
{
	vector<int> v(b,e);
	int *p = new int[v.size()];
	ifstream in("ints");
	// exception occurs here
}

The space "p" points will not be free. There will be a memory leak.

##Exercise 18.3

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.