// File: PascalIntArray.cpp // // Implementation of Pascal-like arrays // derived from vector #include #include #include "PascalIntArray.h" using namespace std ; // Constructors PascalIntArray::PascalIntArray() : vector() { // do nothing } PascalIntArray::PascalIntArray(unsigned int n) : vector(n) { // do nothing } // Copy Constructor PascalIntArray::PascalIntArray(const PascalIntArray& A) : vector(A) { // do nothing } // Destructor PascalIntArray::~PascalIntArray() { // do nothing } // Assignment PascalIntArray& PascalIntArray::operator=(const PascalIntArray& rhs) { vector::operator =(rhs) ; return *this ; } // Redefine [] Operator int& PascalIntArray::operator[](unsigned int i) { return at(i-1) ; } // Sort array using bubble sort void PascalIntArray::bubblesort() { unsigned int i, j ; int temp ; for (i = 1 ; i <= size() - 1 ; i++ ) { for (j = 1 ; j <= size() - i ; j++) { if ( (*this)[j] > (*this)[j+1]) { temp = (*this)[j] ; (*this)[j] = (*this)[j+1] ; (*this)[j+1] = temp ; } } } }