정의하는 클래스 유형 인 클래스에 대한 멤버 함수를 정의 할 수 있습니까?
class aClass {
//Some Stuff
aClass aFunction(. . .);
};
예, 할 수 있으며 매우 편리합니다.
과부하 :
class vec2
{
float x;
float y;
vec2 operator+(vec2 otherVector)
{
vec2 returnVector;
returnVector.x = this.x + otherVector.x;
returnVector.y = this.y + otherVector.y;
return returnVector;
}
}
다음과 같은 작업을 수행 할 수 있습니다.
vec2 myVector = thatVector + theOtherVector;
myVector를 반환 값으로 설정하기 때문에 thatVector + theOtherVector
다른 벡터의 합을 포함하는 벡터가됩니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다