TAILIEUCHUNG - A Complete Guide to Programming in C++ part 28

A Complete Guide to Programming in C++ part 28. This book provides both novice and experienced programmers with a comprehensive resource manual for the C++ programming language. Readers gain experience in all aspects of programming, from elementary language concepts to professional software development, with in depth coverage of all the language elements en route. These elements are carefully ordered to help the reader create useful programs every step of the way. | DEFINING METHODS 249 A class definition is not complete without method definitions. Only then can the objects of the class be used. Syntax When you define a method you must also supply the class name separating it from the function name by means of the scope resolution operator . Syntax type class_name function_name parameter_list . . . Failure to supply the class name results in a global function definition. Within a method all the members of a class can be designated directly using their names. The class membership is automatically assumed. In particular methods belonging to the same class can call each other directly. Access to private members is only possible within methods belonging to the same class. Thus private members are completely controlled by the class. Defining a class does not automatically allocate memory for the data members of that class. To allocate memory you must define an object. When a method is called for a given object the method can then manipulate the data of this object. Modular Programming A class is normally defined in several source files. In this case you will need to place the class definition in a header file. If you place the definition of the class Account in the file any source file including the header file can use the class Account. Methods must always be defined within a source file. This would mean defining the methods for the class Account in a source file named for example. The source code of the application program for example the code containing the function main is independent of the class and can be stored in separate source files. Separating classes from application programs facilitates re-use of classes. In an integrated development environment a programmer will define a project to help manage the various program modules by inserting all the source files into the project. When the project is compiled and linked modified source files are automatically re-compiled and linked to the application .

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.