TAILIEUCHUNG - microsoft visual c 2008 step by step phần 4

và khi bạn chia một số nguyên số nguyên khác, câu trả lời bạn nhận được trở lại là một số nguyên, như được giải thích trước đó. 7. Nhấp vào nút% Phần còn lại, và sau đó nhấp vào Tính toán. Các văn bản trong hộp văn bản thay đổi biểu hiện đến 54 13%, và giá trị 2 sẽ xuất hiện trong hộp văn bản kết quả. Điều này là bởi vì phần còn lại sau khi chia 54 và 13 là 2. | Chapter 9 Creating Value Types with Enumerations and Structs 175 data values where it s just as or nearly as efficient to copy the value as it would be to copy an address. Use classes for more complex data so that you have the option of copying only the address of the actual value when you want to improve the efficiency of your code. Understanding Structure and Class Differences A structure and a class are syntactically very similar but there are a few important differences. Let s look at some of these differences You can t declare a default constructor a constructor with no parameters for a structure. The following example would compile if Time were a class but because Time is a structure it does not struct Time public TimeO . compile-time error . The reason you can t declare your own default constructor for a structure is that the compiler always generates one. In a class the compiler generates the default constructor only if you don t write a constructor yourself. The compiler-generated default constructor for a structure always sets the fields to 0 false or null just as for a class. Therefore you should ensure that a structure value created by the default constructor behaves logically and makes sense with these default values. If you don t want to use these default values you can initialize fields to different values by providing a nondefault constructor. However if you don t initialize a field in your nondefault structure constructor the compiler won t initialize it for you. This means that you must explicitly initialize all the fields in all your nondefault structure constructors or you ll get a compile-time error. For example although the following example would compile and silently initialize seconds to 0 if Time were a class because Time is a structure it fails to compile struct Time public Time int hh int mm hours hh minutes mm compile-time error seconds not initialized . private int hours minutes seconds 176 Part II Understanding the C Language In a .

TỪ KHÓA LIÊN QUAN
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.