انت هنا الان : شبكة جامعة بابل > موقع الكلية > نظام التعليم الالكتروني > مشاهدة المحاضرة
الكلية كلية العلوم للبنات
القسم قسم الحاسبات
المرحلة 2
أستاذ المادة احمد علي حسين الجنابي
06/12/2017 05:52:27
Classes and Objects So far you have explored the structure of a simple program that starts execution at main() and enables you to declare local and global variables and constants and branch your execution logic into function modules that can take parameters and return values. All this is very similar to a procedural language like C, which has no object- orientation to it. In other words, you need to learn about managing data and connecting methods to it. In this lesson, you will learn ? What classes are ? How classes help you consolidate data with methods (akin to functions) that work on them ? About constructors and destructors ? Object-oriented concepts of encapsulation and abstraction ? What this pointer is about Declaring a Class Declaration of a class involves the usage of keyword class followed by the name of the class, followed by a statement block {…} that encloses a set of member attributes and methods within curly braces, finally terminated by a semicolon. A declaration of a class is akin to the declaration of a function. It tells the compiler about the class and its properties. Declaration of a class alone does not make a difference to the execution of a program, as the class needs to be used just the same way as a function needs to be invoked. A class that models a human looks like the following (ignore syntactic short-comings for the moment): class Human { // Data attributes: string Name; string DateOfBirth; string PlaceOfBirth; string Gender; // Methods: void Talk(string TextToTalk); void IntroduceSelf(); … }; Needless to say, IntroduceSelf() uses Talk() and some of the data attributes that are grouped within class Human . Thus, in keyword class, C++ has provided you with a powerful way to create your own data type that allows you to encapsulate attributes
المادة المعروضة اعلاه هي مدخل الى المحاضرة المرفوعة بواسطة استاذ(ة) المادة . وقد تبدو لك غير متكاملة . حيث يضع استاذ المادة في بعض الاحيان فقط الجزء الاول من المحاضرة من اجل الاطلاع على ما ستقوم بتحميله لاحقا . في نظام التعليم الالكتروني نوفر هذه الخدمة لكي نبقيك على اطلاع حول محتوى الملف الذي ستقوم بتحميله .
|