TAILIEUCHUNG - Thinking in C plus plus (P8)

Tham khảo tài liệu 'thinking in c plus plus (p8)', 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ả | class X void f the function f inside the scope of class X does not clash with the global version of f . The compiler performs this scoping by manufacturing different internal names for the global version of f and X f In Chapter 4 it was suggested that the names are simply the class name decorated together with the function name so the internal names the compiler uses might be _f and _X_f However it turns out that function name decoration involves more than the class name. Here s why. Suppose you want to overload two function names void print char void print float It doesn t matter whether they are both inside a class or at the global scope. The compiler can t generate unique internal identifiers if it uses only the scope of the function names. You d end up with _print in both cases. The idea of an overloaded function is that you use the same function name but different argument lists. Thus for overloading to work the compiler must decorate the function name with the names of the argument types. The functions above defined at global scope produce internal names that might look something like _print_charand _print_float It s worth noting there is no standard for the way names must be decorated by the compiler so you will see very different results from one compiler to another. You can see what it looks like by telling the compiler to generate assembly-language output. This of course causes problems if you want to buy compiled libraries for a particular compiler and linker - but even if name decoration were standardized there would be other roadblocks because of the way different compilers generate code. That s really all there is to function overloading you can use the same function name for different functions as long as the argument lists are different. The compiler decorates the name the scope and 330 Thinking in C www. BruceEckel .com the argument lists to produce internal names for it and the linker to use. Overloading on return values It s common to wonder Why

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.