Untitled
By: a guest | Mar 15th, 2010 | Syntax:
C++ | Size: 0.79 KB | Hits: 41 | Expires: Never
#include "vektor.h"
#include <iostream>
int Vektor::defMeret=3;
double Vektor::defErtek=-26;
Vektor::~Vektor (){if(pVec!=NULL) delete []pVec;};
Vektor::Vektor(const Vektor& vt) {
nElem=vt.nElem;
if(pVec!=NULL) delete[] pVec;
pVec=new double[nElem];
for(int i=0;i<nElem;i++) pVec[i]=vt.pVec[i];};
double& Vektor::operator[](int idx){
if (idx<0) throw "Az index nem lehet kisebb mint 0.";
if (idx>=nElem) throw "Tulindexeles.";
return pVec[idx];};
Vektor& Vektor::operator=(const Vektor& vt){
nElem=vt.nElem;
pVec=new double[nElem];
for(int i=0;i<nElem;i++) pVec[i]=vt.pVec[i];
return *this;};
Vektor operator*(double a, Vektor& vt){
Vektor tmp;
tmp.pVec=new double[tmp.nElem=vt.nElem];
for(int i=0;i<tmp.nElem;i++) tmp.pVec[i]=a*vt.pVec[i];
return tmp;};