C++의 intro 수준 클래스에서 퀴즈를 풀고 질문을 이해하려고합니다. 인터넷을 검색하고 답을 얻지 못하면 여기 있습니다. fstream, ofstream, ostream에, iostream :fstream, ofstream, ostream, iostream의 차이점
Which of the following function declarations will accept either cout or a file stream
object as its argument?
A. void output(fstream &outFile);
B. void output(ofstream &outFile);
C. void output(ostream &outFile);
D. void output(iostream &outFile);
대답은 내가 차이를 알고 C.
입니다.
다른 옵션 중 하나도 인수 또는 파일 스트림 객체를 인수로 사용할 수없는 이유는 무엇인지 이해할 수 없습니다.
ostream 객체가 인수로 전달할 수있는 데이터 (char, 등)를 포함하는 것처럼 간단합니까?
모든 정보는 크게 감사하겠습니다.
아마도이 [이 C++ I/O 참조] (http://en.cppreference.com/w/cpp/io) 및 상속 계층 구조 다이어그램이 도움이 될 수 있습니까? –
관련 항목 : [기본 클래스를 매개 변수로 사용하는 함수를 참조하여 파생 클래스를 전달할 수 있습니까?] (https://stackoverflow.com/questions/9285627/is-it-possible-to-pass-derived-classes- by-reference-to-a-function-taking-base-cl) – Borgleader
파일 스트림을 입출력 할 수 있기 때문에'D '를 선택했습니다. 답변'C' 만 출력됩니다. –