執行個體解析C++/CLI的輸入與輸出

來源:互聯網
上載者:User

當使用標準C++編程時,我們已開始接觸到兩個主要的I/O"工具":標準C標頭檔cstdio和標準C++中與流相關的標頭檔iostream,如果加上Windows的話,那麼還有Win32庫和MFC庫,另外,還有CLI/.NET。本文將要探討的,就是C++/CLI中的輸入與輸出。

簡介

日常,我們與檔案或裝置進行通訊的邏輯通道,稱為流。資料可以8位位元組或16位Unicode字元形式進行讀寫,而兩者都有其自己的類集;另外,還有用於在位元組與字元之間轉換的類。其中,字元流通過Stream類及其的衍生類別實現;字元流通過TextReader與TextWriter類及其的衍生類別實現。

在圖1中示範了標準I/O的類繼承關係。(帶有System命名空間首碼的類與I/O無關,但其卻是I/O類的基類。)

圖1:標準I/O類繼承關係

  System::Object
    System::Attribute
     System::ComponentModel::MemberAttribute
      System::ComponentModel::DescriptionAttribute
       IODescriptionAttribute
    System::ComponentModel::Component
     FileSystemWatcher
    System::Delegate
     FileSystemEventHandler
      RenamedEventHandler
    System::EventArgs
     FileSystemEventArgs
     RenamedEventArgs
    System::Exception
     IOException
      DirectoryNotFoundException
      EndOfStreamException
      FileNotFoundException
     PathTooLongException
     System::SystemException
     InternalBufferOverflowException
    BinaryReader
    BinaryWriter
    FileSystemEntry
     Directory
     File
    Stream
     BufferedStream
     FileStream
     MemoryStream
    TextReader
     StreamReader
     StringReader
    TextWriter
     StreamWriter
     StringWriter
    System::ValueType
     System::Enum
      ChangedFilters
      FileAccess
      FileMode
      FileShare
      FileSystemAttributes
      SeekOrigin
      WatcherChangeTypes
      WatcherTarget
    WaitForChangedResult

每當一個程式運行時,會自動為我們開啟三個流,分別是:

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.