Hello I am a relatively new programmer with C++. I had a question about my code
I have a point 2d class that has a double x and y.
I am trying the following nested loop:
Point2D Dec(float t)
{
Point2D Temp;
vector<Point2D>Bcopy=H->B;
for(int p=0;p<Bcopy.size()-1;p++){
for(int l=p;l<Bcopy.size();l++){
Temp=(1-t)*Bcopy.at[p][l-1]+t*Bcopy.at[p+1][l-1];
}
}
return Temp;
}
So essentially there is another class that has a vector with point 2d B and H is the pointer to it. These are storing the points from mouse interaction etc and drawing them. So i just created a copy of it and then did the above nested loop and then I use the points to draw them too.
I keep getting the following two errors:
std::vector<Point2D,std::allocator<-Ty>>::at':function call missing argument list;use'&std::vector<Point2D,std::allocator<_Ty>>:at' to create a pointer to member
and
subscript requires array or pointer.
Both these errors are for the line
Temp=(1-t)*Bcopy.at[p][l-1]+t*Bcopy.at[p+1][l-1]
in the code
I have tried many different things and I either keep getting more errors or just these two. I tried to google and understand the errors but couldn't really. Any help would be much appreciated
Thank you
EDIT After much playing around
I did the following:
vector<2D>NewBcopy;
double Rx=0 ,Ry=0;
for(int p=0;p<Bcopy.size()-1;p++){
for(int l=p;l<Bcopy.size();l++){
if(l==p)
{Newcopy.at(l)=Bcopy.at(l);
}
else
{Rx=(1-t)*Bcopy.at(p).x+t*Bcopy.at(p+1).x;
Ry=(1-t)*Bcopy.at(p).y+t*Bcopy.at(p+1]).y:
}
Temp.x=Rx;
Temp.y=Ry;
}
}
return Temp;
}