Skip to content

C++ 5day  #9

Description

@KangHoyong

파일 입출력

  • ifstream , ofstream, fstream
#include <fstream>
int main()
{
     ofstrema output ; 
     // new file 
     output.open("test.txt"); 

      // 파일 존재 여부 검사 
      if(output.fail())
      {
           cout << "File does not exist" << endl; 
           cout << "Exit program " << endl;
       }
     // 쓰기 
     output << " jonew " << endl; 
    // 닫기 
    output.close();
    cout << "Done" << endl;
 
     string a ; 
     // 파일 읽기 
    output.open("test.txt", ios::in); 
    while (!output.eof()) // 파일의 끝이 아니면 계속 실행 
    { 
            output >> a;            
            cout << a;
     } 

    output.close();

    return  0 ; 
}
  • 이진 배열 입출력

참고

연산자 오버로딩

상속과 다형성

다향성 참고

예외 처리

재귀 호출

class get / set 쓰는 이유

Get - 멤버변수는 보통 Private이라, 다른데서도 가져다 쓸 수있게 만들어 주는 함수
Set - 멤버변수에 접근하여 새로운 값을 주는 함수

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions