#ifndef IUGRINA_CNvektor20061211
#define IUGRINA_CNvektor20061211

// klasa za n-dimenzionalni vektor

#include <iostream>
#include "complex-v10_projekt1.hpp"

class CNvektor{
  
  // velicina vektora (dim prostora)
  int n;

  // pokazivac na polje Complex brojeva
  Complex *pc;
  
  void destruktor(){
    if(pc){
      delete [] pc;
    }
    n=0;
    pc=0;
  }
  
public:

  CNvektor():n(0),pc(0){}
  
  CNvektor( int dim):n(dim){
    pc=new Complex[dim];
    for(int i=0; i<dim; ++i){
      *(pc+i)=Complex();
    }
  }

  // copy konstruktor
  CNvektor( const CNvektor &v):n(v.n){
    pc=new Complex[v.n];
    for(int i=0; i<v.n; ++i){
      *(pc+i)=*(v.pc+i);
    }
  }
  
  CNvektor( const Complex &z):n(1){
    pc=new Complex(z);
  }
  
  ~CNvektor(){
    destruktor();
  }
  
  CNvektor& operator=(const CNvektor &v){
    destruktor();
    
    n=v.n;
    pc=new Complex[n];
    for(int i=0; i<v.n; ++i){
      *(pc+i)=*(v.pc+i);
    }
  }
  
  bool operator!=( const CNvektor &v) const{
    if(n!=v.n){
      return true;
    }
    else{
      for( int i=0; i<n; ++i){
        if( *(pc+i) != *(v.pc+i) ){
          return true;
        }
      }
      
      return false;
    }
  }
  
  friend bool operator==(const CNvektor &v1, const CNvektor &v2);
  
  Complex& operator[](int i) const{
    if(i<0 || i>n-1){
      throw "!!Number is out of range!!";
    }
    else{
      return *(pc+i);
    }
  }
  
  friend CNvektor operator+( const CNvektor &v1, const CNvektor &v2);
  friend CNvektor operator-( const CNvektor &v1, const CNvektor &v2);
  friend Complex operator*( const CNvektor &v1, const CNvektor &v2);
  
  friend std::ostream& operator<<( std::ostream &iz, const CNvektor &z);
  friend std::istream& operator>>( std::istream &iz, CNvektor &z);
  

};

#endif


