필요 :는 제가 도움이 필요 무엇을 당신에게 예를 들게 도움말 다형성
Main 클래스 :
cnd:Currency
usd:Currency
cc:Combined_Currency
usd := cc.usd
cnd := cc.cnd
그래서, 클래스 Combined_Currency
클래스 Currency
있습니다. Currency 클래스에는 예를 들어 exchange_rate
과 같은 속성이 있습니다. 어떻게이 exchange_rate
부분을 구현합니까있다
cnd:Currency
usd:Currency
내 질문 : 나는 Combined_Currency
클래스가 같은있을 것입니다 생각? Exchange_rate는 상수이기 때문에 아무 것도 설정할 필요가 없습니다. 다음을 확인해야합니다 : cad.exchange_rate = 1.5
exchange_rate를 해당 통화로 설정하는 클래스는 무엇입니까? 누군가가 내게 어떤 아이디어를 줄 수 있는지 cad := cc.cad
의미합니다.
'Combined_Currency' 클래스에서'cnd.exchange_rate : = 1.5'를 시도했지만 컴파일 오류가 있습니다. – J0natthaaann
"cnd.exchange_rate : = 1.5"를 수행하려면 할당자를 사용해야합니다. 참조 : http://docs.eiffel.com/book/examples/example-self-initializing-attributes-and-assigner-commands. 또한 exchange_rate가 상수이어야하고 클래스 클라이언트에서 값을 할당하려고하는 이유는 무엇입니까? –
음, 처음에는'cnd.exchange_rate'에 값을 할당해야합니다. – J0natthaaann