#include
#include
#include "xcept.h"
class Array1D{
friend istream& operator<<(ostream&,const Array1D&); public: Array1D(int size=0); Array1D(const Array1D& v); ~Array1D(){delete [] element;} int& operator[](int i)const; int Size(){return size;} Array1D& operator=(const Array1D& v); Array1D operator+()const; Array1D operator+(const Array1D& v)const; Array1D operator-()const; Array1D operator-(const Array1D& v)const; Array1D operator*(const Array1D& v)const; Array1D& operator+=(const int& x); Array1D& Resize(int sz); private: int size; int* element; }; Array1D::Array1D(int sz){ if(sz<0)throw size="sz;" element="new" size="v.size;" element="new" i="0;" int="" i=""><0||i>=size)throw OutOfBounds();
return element[i];
}
Array1D& Array1D::operator=(const Array1D& v){
if(this !=&v){
size=v.size;
delete[]element;
element=new int[size];
for(int i=0;i
element[i]=element[i];
}
return* this;
}
Array1D Array1D::operator+(const Array1D& v)const{
if (size != v.size) throw SizeMismatch();
Array1D w(size);
for(int i=0; i
w.element[i]=element[i]+v.element[i];
return w;
}
Array1D Array1D::operator-(const Array1D& v)const{
if(size != v.size) throw SizeMismatch();
Array1D w(size);
for(int i=0; i
w.element[i]=element[i]-v.element[i];
return w;
}
Array1D Array1D::operator-()const{
Array1D w(size);
for(int i=0; i
w.element[i]=-element[i];
return w;
}
Hasil Output :
About Me
Statistik
Live Traffic Feed
Daftar Blog Teman
Link
Blogroll
Didukung
Followers
- Anak Indonesia Harapan Masa Depan (1)
- APBO (1)
- Basis Data (2)
- ERD (1)
- MySQL (1)
- Pendidikan (3)
- Peran Perbankan dan Koperasi dalam mendorong peningkatan kewirausahaan di Indonesia (1)
- PHP (2)
- Programing C++ (8)
- Sewa Ruang Kantor Jakarta Murah (1)
- Sistem Operasi (6)
- Struktur Data (1)
- Web Desain (4)
- Web Dinamis (2)
Langganan:
Posting Komentar (Atom)
0 komentar:
Posting Komentar