Thinking in C++ 2nd edition Volume 2 Standard Libraries & Advanced Topics revision 1 phần 2

"Cuốn sách này là một thành tựu to lớn. Bạn nợ cho chính mình để có một bản sao trên thềm lục địa của bạn. Các chương trên iostreams là phương pháp điều trị toàn diện và dễ hiểu nhất rằng chủ đề tôi đã nhìn thấy cho đến nay. " | out startLevel htmlLine endLevel endl break Out of while loop Item contains a private member function removeBar that is used internally to strip off the leading bars if they appear. The constructor for Item initializes depth to 0 to indicate that no signs were found yet if none are found then it is assumed the Item should be displayed at level one. Each character in the string is examined using operator to find the depth id and url values. The other member functions simply return these values. After opening the files main uses string find to locate the line containing the site map data. At this point substr is used in order to strip off the information before and after the site map data. The subsequent while loop performs the parsing but notice that the value index is passed by reference into the Item constructor and that constructor increments index as it parses each new Item thus moving forward in the sequence. If an Item is at level one then an HTML h1 tag is used otherwise the elements are indented using HTML non-breaking spaces. Note in the initialization of htmlLine how easy it is to construct a string - you can just combine quoted character arrays and other string objects using operator . When the output is written to the destination file startLevel and endLevel will only produce results if they have been given any value other than their default initialization values. Summary C string objects provide developers with a number of great advantages over their C counterparts. For the most part the string class makes referring to strings through the use of character pointers unnecessary. This eliminates an entire class of software defects that arise from the use of uninitialized and incorrectly valued pointers. C strings dynamically and transparently grow their internal data storage space to accommodate increases in the size of the string data. This means that when the data in a string grows beyond the limits of the memory initially allocated to it the string .

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
15    74    2    29-04-2024
Đã 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.