것은 당신이, C++를 사용하고 있기 때문에, 당신은 참조를 사용할 수 있습니다
void trans(double x, double y, double theta, double& m, double& n)
{
m=cos(theta)*x+sin(theta)*y;
n=-sin(theta)*x+cos(theta)*y;
}
int main()
{
// ...
// no special decoration required for xc and yc when using references
trans(center_x, center_y, angle, xc, yc);
// ...
}
당신이 C를 사용한다면, 당신은 명시 적 포인터 또는 주소를 통과해야 반면, 같은 로 :
void trans(double x, double y, double theta, double* m, double* n)
{
*m=cos(theta)*x+sin(theta)*y;
*n=-sin(theta)*x+cos(theta)*y;
}
int main()
{
/* ... */
/* have to use an ampersand to explicitly pass address */
trans(center_x, center_y, angle, &xc, &yc);
/* ... */
}
나는 참조를 제대로 사용하는 방법에 대한 자세한 내용은 C++ FAQ Lite's entry on references을 확인하는 것이 좋습니다.
관련 질문 예 : http://stackoverflow.com/questions/410593/pass-by-reference-value-in-c, http://stackoverflow.com/questions/1322517/passing -a-modifiable-parameter-to-c-function – outis
요청 요청 ... 숙제 문제! 대답 키 이외에는 스택 오버플로를 사용하십시오. – bobby