12.05.2015 Views

type - David Vernon

type - David Vernon

type - David Vernon

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Object-Oriented Programming<br />

A Class for Sets - Application<br />

static int *memoryspace(int *p0, int n0, int n1)<br />

/* if p0 == NULL, allocate an area for n1 integers */<br />

/* if p0 != NULL, increase or decrease old sequence */<br />

/* p0[0], ... , p[n0-1] */<br />

/* in either case, the resulting new sequence is */<br />

/* p1[0], ..., p1[n1-1], and p1 is returned */<br />

{ int *p1 = new int[n1];<br />

if (p0 != NULL) // copy from p0 to p1:<br />

{ for (int i=(n0=0; i--)<br />

p1[i] = p0[i];<br />

delete p0;<br />

}<br />

return p1;<br />

}<br />

Copyright © 2007 <strong>David</strong> <strong>Vernon</strong> (www.vernon.eu)

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!