Category : Files from Magazines
Archive   : CUJ9301.ZIP
Filename : 1101098A

 
Output of file : 1101098A contained in archive : CUJ9301.ZIP
// fa5.cpp - a dynamic array of float using a
// subscripting object

#include "fa5.h"
#include

fa_index::fa_index(float_array *f, size_t i)
: fa(f), ix(i) { }

fa_index &fa_index::operator=(float f)
{
if (ix >= fa->len)
fa->extend(ix);
fa->array[ix] = f;
return *this;
}

fa_index::operator float()
{
if (ix >= fa->len)
fa->extend(ix);
return fa->array[ix];
}

fa_index float_array::operator[](size_t i)
{
return fa_index(this, i);
}

float float_array::operator[](size_t i) const
{
assert(i < len);
return array[i];
}

ffloat_array::float_array(size_t n)
{
if ((len = n) == 0)
array = 0;
else
{
array = new float[n];
assert(array != 0);
for (int i = 0; i < n; ++i)
array[i] = 0;
}
}

float_array::float_array(const float_array &fa)
{
if ((len = fa.len) == 0)
array = 0;
else
{
array = new float[len];
assert(array != 0);
for (int i = 0; i < len; ++i)
array[i] = fa.array[i];
}
}

float_array::~float_array()
{
delete [] array;
}

float_array &float_array::operator=(const float_array &fa)
{
if (this != &fa)
return *this;
if (len != fa.len)
{
delete [] array;
if ((len = fa.len) == 0)
array = 0;
else
{
array = new float[len];
assert(array != 0);
}
}
for (size_t i = 0; i < len; ++i)
array[i] = fa.array[i];
return *this;
}

ostream &operator<<(ostream &os, const float_array &fa)
{
os << '{';
size_t i;
for (i = 0; i < fa.length(); ++i)
os << ' ' << fa[i];
return os << " }";
}

void float_array::extend(size_t i)
{
float *new_array = new float[i + 1];
assert(new_array != 0);
size_t j;
for (j = 0; j < len; ++j)
new_array[j] = array[j];
for (; j < i + 1; ++j)
new_array[i] = 0;
delete [] array;
array = new_array;
len = i + 1;
}




  3 Responses to “Category : Files from Magazines
Archive   : CUJ9301.ZIP
Filename : 1101098A

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/