1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
#include <iostream>
using namespace std;
void offsetvector(double &x0, double &y0, double &x1, double &y1, double offsetX, double offsetY)
{
x0 += offsetX;
x1 += offsetX;
y0 += offsetY;
y1 += offsetY;
}
void printvector(double x0, double y0, double x1, double y1)
{
cout << "(" << x0 << "," << y0 << ") -> (" << x1 << "," << y1 << ")" << endl;
}
int main()
{
double xStart = 2.1;
double yStart = 2.2;
double xEnd = 4.1;
double yEnd = 4.2;
offsetvector(xStart, yStart, xEnd, yEnd, 1.0, 1.5);
printvector(xStart, yStart, xEnd, yEnd);
}
|
But if i change offsetvector function to this:
...
&x0 += offsetX;
&x1 += offsetX;
&y0 += offsetY;
&y1 += offsetY;
...
or
&y1 = 20.0;
or
&y1 = &y0; |