tailieunhanh - Core C++ A Software Engineering Approach phần 4

mã khách hàng sử dụng thành viên chức năng getVolume (), scaleCylinder (), và do đó chứ không phải là truy cập vào các giá trị của lĩnh vực bán kính và chiều cao. Đây là những gì dòng tiêu tan có nghĩa là. Nó cho thấy rằng truy cập trực tiếp vào dữ liệu được loại trừ. | file Administrator General 20English 20Learning it2002-7-6 void swap int a1 int a2 correct parameter mode int Simpo PDF Merge and Split Unregistered Version - http if a1 a2 Oh boy cout Before swap a1 a1 a2 a2 endl temp a1 a1 a2 a2 temp correct dereferencing cout After swap a1 a1 a2 a2 endl int main int x 82 y 42 values are out of order int x 42 y 84 values are ordered swap x y correct parameter mode it should work cout After call x x y y endl return 0 By the way this is not a contrived example. This is a scaled-down version of what happened to me in real life. I made the situation easier to review by removing extraneous details. So where were we Oh yes. A good mnemonic rule for passing parameters by pointer is When you choose the name for a parameter you must start this name with the asterisk and remember to use this asterisk as part of the name on all occasions. The trouble with my first version of swap and alas with the second version too was that I thought that the parameter names were a1 and a2. This was not productive. Had I thought from the very beginning that their names were a1 and a2 throughout writing this function as in Listing would have been a breeze including the use of a1 a2 in the conditional statement. Still this is much more complex than passing parameters by value. You have to Tn use the pointer notation in the function header and the prototype Tn dereference parameters inside the body of the function Tn use the address-of operator outside of the function in the client code. As your reward changes made to parameters are reflected in actual arguments in the client code Everybody makes mistakes in passing parameters by pointer. The only difference between experienced and inexperienced programmers is that experienced programmers make these errors less often and correct them faster. As for the anguish and self-criticismjK Well I told you that you should never criticize yourself. After all it was not you who invented .

TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
8    193    0    23-05-2024
37    169    0    23-05-2024
10    128    0    23-05-2024
173    112    0    23-05-2024
11    159    1    23-05-2024
6    107    0    23-05-2024
crossorigin="anonymous">
Đã 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.