TAILIEUCHUNG - C++ Timesaving Techniques for Dummies phần 6

Trong trình soạn thảo mã của sự lựa chọn của bạn, tạo ra một tập tin mới để giữ mã cho việc thực hiện của tập tin nguồn. Trong ví dụ này, tập tin được đặt tên là , mặc dù bạn có thể sử dụng bất cứ điều gì bạn chọn. | Reading Delimited Files 235 1. In the code editor of your choice create a new file to hold the code for the implementation of the source file. In this example the file is named although you can use whatever you choose. 2. Type the code from Listing 42-1 into your file. Better yet copy the code from the source file on this book s companion Web site. Listing 42-1 Reading a Delimited File include include string include vector include iostream include fstream Avoid having to type out std for all STL classes. using namespace std This class manages a list of delimiters. class Delimiters - 1 private Array of possible delimiters. Use a vector since the characters could include NULL byte or other characters that string can t handle. vector char _delimiters protected virtual void Copy const Delimiters aCopy vector char const_iterator iter for iter iter iter _delimiters. end iter public Delimiters void Delimiters const char delimiterList for int i 0 i strlen delimiterList i _delimiters. end delimiterList i Delimiters const Delimiters aCopy Copy aCopy Delimiters operator const Delimiters aCopy Copy aCopy virtual Delimiters void Clear out the entire list. virtual void Clear _delimiters. begin Add a delimiter to the list. virtual void Add char c _delimiters. end c See whether a given character is in the list. virtual bool Contains char c vector char const_iterator iter for iter iter iter if c iter return true return false Remove a given delimiter. virtual bool Remove char c vector char iterator iter for iter iter iter if c iter continued Technique 42 How to Read Delimited Files Listing 42-1 continued iter return true return false This class manages the data for a given row of a delimited file. class DelimitedRow - 2 private vector string .

TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.