헤더 파일 (.H) :인스턴스 개체는 함수의 private 멤버를 개체 매개 변수로 어떻게 볼 수 있습니까?
bool canTravelWith(const Passenger&) const;
구현 파일 (통화 당) :
bool Passenger::canTravelWith(const Passenger& x) const
{
bool canTravel = false;
//if both passengers have the same destination on the same date...
if (strcmp(x.m_destination,this->m_destination) == 0 && x.m_year == this->m_year && x.m_month == this->m_month && x.m_day == this->m_day)
{
canTravel = true;
}
return canTravel;
}
얘들 아,
작품 위의 코드를하지만 내가 알고 싶어하는 것은 경우입니다 매개 변수의 객체의 멤버는 비공개로 액세스됩니다. 내 canTravelWith() 내에서 해당 객체의 멤버를 어떻게 호출 할 수 있습니까?
다른 경우; 나는 사물의 사적인 구성원을 부를 수 없다.
왜 그런지 이해하고 싶습니다.
감사합니다. (:..
수업의 비공개 회원에게 액세스하는 것이 혼란 스럽습니다. 그게 무슨 문제입니까? –
그럼 왜 승객 클래스에서 승객 클래스에 액세스 할 수 있습니까? 뭐? [좋은 책] (https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list)을 읽는 것을 고려하십시오. –