Đang chuẩn bị liên kết để tải về tài liệu:
HandBooks Professional Java-C-Scrip-SQL part 65

Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ

Tham khảo tài liệu 'handbooks professional java-c-scrip-sql part 65', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | std cout This any contained a boost shared_ptr A n ptr- is_virtual ptr- not_virtual return catch boost bad_any_cast e Try boost shared_ptr B try boost shared_ptr B ptr boost any_cast boost shared_ptr B a std cout This any contained a boost shared_ptr B n ptr- is_virtual ptr- not_virtual return catch boost bad_any_cast e If anything else like just a string ignore it std cout The any didn t contain anything that concerns this function n In main we create two anys at function scope. We then introduce a new scope and create two new anys. Next we store all of the anys in the vector and send every element in it to the function foo which examines their contents and exercises them. It should be duly noted that we are actually violating the advice that was given earlier to use the pointer form of any_cast when a failure does not designate an error. However because we are dealing with smart pointers here the syntactic advantage of using the exception-throwing form of any_cast is reason enough to ignore the advice this time. int main std cout Example of any and shared_ptr n boost any a1 boost shared_ptr A new A boost any a2 std string Just a string boost any b1 boost shared_ptr A new B boost any b2 boost shared_ptr B new B std vector boost any vec vec.push_back a 1 vec.push_back a2 vec.push_back b1 vec.push_back b2 std for_each vec.begin vec. end foo std cout n std cout any s bl and b2 have been destroyed which means n that the shared_ptrs reference counts became zero n When this program is run it produces the following output. Example of any and shared_ptr This any contained a boost shared_ptr A A is_virtual A not_virtual The any didn t contain anything that concerns this function This any contained a boost shared_ptr A B is_virtual A not_virtual This any contained a boost shared_ptr B B is_virtual B not_virtual A A A A First we see that the any passed to foo contains a shared_ptr A which also happens to own an instance of A. The output is what one would expect. Next the any

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.