Teach Yourself Visual C++ 6 in21 Days phần 6

. Xác định rõ loại chức năng như CPerson * (một con trỏ đến các lớp tuỳ chỉnh), tên chức năng là GetLastRecord, và truy cập như công chúng. Chỉnh sửa chức năng, thêm mã trong Khi điền vào các chức năng tuần tự trong lớp tài liệu, Lưu và khôi phục truy cập file làm việc | Creating Your Own Classes and Modules 381 I Let s look at how this could work with a thermostat. Suppose you had a basic thermostat that you could use in just about any setting. You could set the temperature for it to maintain and it would turn on the heating or the air-conditioning as needed to maintain that temperature. Now let s say you needed to create a thermostat for use in a freezer. You could start from scratch and build a customized thermostat or you could take your existing thermostat and specify how the freezer version differs from the original. These differences might include that it s limited to turning on the air conditioning and could never turn on the heater. You would probably also put a strict limit on the range of temperatures to which the thermostat could be set such as around and below 32 Fahrenheit or 0 Celsius. Likewise if you needed a thermostat for an office building you would probably want to limit the temperature range to what is normally comfortable for people and not allow the temperature to be set to an extremely cold or hot setting. With inheritance in creating your own classes this method just described represents the same principle that you want to apply. If possible you should start with an existing C class that has the basic functionality that you need and then program how your class is different from the base class that you inherited from. You have the ability to add new data elements extend existing functionality or override existing functionality as you see fit. 16 Visual C Class Types In most application projects when you are creating a new class you have a few options on the type of class that you are creating. These options are Generic class MFC class Form class Which of these types of classes you choose to create depends on your needs and what your class will be doing. It also depends on whether your class needs to descend from any of the MFC classes. Generic Class You use a generic class for creating a class that is .

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
Đã 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.