-
카테고리
-
세부 분야
프로그래밍 언어
-
해결 여부
미해결
cout<<mon 질문
21.09.18 22:12 작성 조회수 163
0
#include "monster.h"
using namespace std;
int main(int argc, const char * argv[]) {
Monster mon1("sanson",position2D(0,0));
cout<<mon1<<endl;
mon1.moveTo(position2D(1,1));
cout<<mon1<<endl;
return 0;
}
지금과 같이 cout<<mon1할때 location의 멤버변수들이 다 출력되는 것이 궁금합니다.
mon1의 friend std::ostream& operator << (std::ostream &out, const Monster& mon){
//out << mon.m_name << " " << mon.m_x << " " << mon.m_y << std::endl;
out<<mon.m_name<<" "<<mon.m_location<<std::endl;
return out;
}를 보면 m_location을 출력시키는 거잔항요 location을 출력하면 location의 멤버변수도 출력된다는게 어디있는건가요?
답변을 작성해보세요.
답변 2