13.01.2015 Views

Объектно-ориентированное программирование на С++ - eDrive

Объектно-ориентированное программирование на С++ - eDrive

Объектно-ориентированное программирование на С++ - eDrive

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

100<br />

struct computer { AnsiString name; int price; };<br />

class VList {<br />

computer *p;<br />

int i, max, current;<br />

public:<br />

VList (int);<br />

void Add (computer *);<br />

void Delete (computer *);<br />

AnsiString Out ();<br />

};<br />

VList::VList (int max) { VList::max = max; current = 0; p = new computer[max]; }<br />

void VList::Add (computer *v) {<br />

if (current < max) {<br />

p[current].name = v–>name;<br />

p[current++].price = v–>price;<br />

}<br />

}<br />

void VList::Delete (computer *v) {<br />

for (i=0; iname) {<br />

while (i < current–1) {<br />

p[i].name = p[i+1].name;<br />

p[i].price = p[i+1].price;<br />

i++;<br />

}<br />

––current;<br />

}<br />

}<br />

}<br />

AnsiString VList::Out () {<br />

AnsiString result;<br />

for (i=0; i

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

Saved successfully!

Ooh no, something went wrong!