انت هنا الان : شبكة جامعة بابل > موقع الكلية > نظام التعليم الالكتروني > مشاهدة المحاضرة

OOP

Share |
الكلية كلية العلوم للبنات     القسم قسم الحاسبات     المرحلة 2
أستاذ المادة حسنين علي عبيس عبود آل عيسى       13/03/2019 18:41:44
What is OOP?
Last year we 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.
The Concept of Classes and Objects
Imagine you are writing a program that models a human being, like yourself. This
human being needs to have an identity: a name, a date of birth, a place of birth, and
a gender. The human can perform certain functions, such as talk and introduce him-
or herself, among others. Now, the former information is data about the human being,
whereas the latter information comprises functions as illustrated by Figure below.
Organizing Code with Functions
Functions give you a way to compartmentalize and organize your program’s execution
logic. They enable you to split the contents of your application into logical blocks that
are invoked sequentially. A function is hence a subprogram that optionally takes
parameters and returns a value, and it needs to be invoked to perform its task. In this
lesson you learn
Function prototypes and function definition
Passing parameters to functions and returning values from them
Reference arguments
Overloaded function
Inline function
What Is a Function Prototype?
The function prototype basically tells what a function is called (the name of function),
the list of parameters the function accepts (one or more parameters) and the return
type of the function.
The function prototype is called (the name, Area), the list of parameters the function
accepts (one parameter, a double called InputRadius) and the return type of the
function (a double).
Without the function prototype, on reaching Lines 16 and 19 in main() the compiler
wouldn’t know what the terms Area and Circumference are. The function prototypes
tell the compiler that Area and Circumference are functions; they take one parameter
of type double and return a value of type double. The compiler then recognizes these
statements as valid and the job of linking the function call to its implementation and
ensuring that the program execution actually triggers them is that of the linker.
Note: A function can have multiple parameters separated by commas, but it can have only one return
type. When programming a function that does not need to return any value, specify the return type as
void

المادة المعروضة اعلاه هي مدخل الى المحاضرة المرفوعة بواسطة استاذ(ة) المادة . وقد تبدو لك غير متكاملة . حيث يضع استاذ المادة في بعض الاحيان فقط الجزء الاول من المحاضرة من اجل الاطلاع على ما ستقوم بتحميله لاحقا . في نظام التعليم الالكتروني نوفر هذه الخدمة لكي نبقيك على اطلاع حول محتوى الملف الذي ستقوم بتحميله .
الرجوع الى لوحة التحكم