lundi 26 mars 2018

How to add pointer array references to another method

I have this method

      int Vector::size()
          {
    std::cout<<"enter vector values: "<<std::endl;
    double vel[_size];
    _elems=vel;
    for(int i=0;i<_size;++i)
    {
        std::cin>>vel[i];//inserts the value to vector
    }
    return _size;
}

i want to get the array value to another method

 double& Vector::operator *(Vector& vector)
    { double res;
        for (int i=0;i<_size;++i){
            res+=vector.*_elems;
        }
        return res;
    }

without creating another argument or global variable in the vector class

Aucun commentaire:

Enregistrer un commentaire