Object Oriented Languages. Object Oriented Programming Basics

- . - , , , . , , .

. - , :

  • ;
  • ;
  • .

, , .

OOP two languages




- :

  1. Pascal. Delphi 7 Delphi. Object Pascal - .
  2. C++ , . , , , , , .
  3. Java - -, Java. . : Standard Edition, Enterprise Edition, Micro Edition, Card.
  4. JavaScript web-. Java. Ecmascript. Ecmascript , JScript, ActionScript.
  5. Objective-C , Objective-C.
  6. Perl - . , . , , , . .
  7. PHP. . -, . gui- PHP-GTK, PHP-Qt, WinBinder.
  8. Python - , . Cython, , Python .

“- ” - . . , , .





. . .

: .

- - .

Class inheritance




, . , , , . , , , . - .

:

  • ;
  • .

, - . .

:

class Animal {

function draw() {

return "just animal";

}

function eat() {

return "the animal is eating";

}

}

class Cow extends Animal {

function draw() {

Return "something that looks like a cow";

}

}

, class Cow class Animal. , Cow.eat(), "the animal is eating", , draw() . Cow.draw() “something that looks like a cow”, Animal.draw() “just animal”.





, . private.

Private specifier




, . , , .

class Animal {

private $name;

function __construct($name) {

$this->name = $name;

}

function getName() {

return $this->name;

}

}

Name . , name. , , .

, .

Polymorphism example




. class CardDesk class GraphicalObject. draw(). , .

Ad hoc :

  • , ;
  • .

, .

. - , , , - .

« — » .

- , .

Class example




. , . :

  • ;
  • ;
  • .

, . , . , - .

. - .

Object Pascal :

ClassName = class(SuperClass)

private

{ }

{ }

strict private

{ Delphi 2007, , private }

protected

{ ClassName }

public

{ }

published

{ , Object Inspector'e }

end;

SuperClass - , .

C++ :

class MyClass: public Parent

{

public:

MyClass(); //

~MyClass(); //

protected:

private:

};

Parent , . private, public, protected , . , , . C++ private, , .

- - , . :

  • ;
  • .

. , - , , . , .

- , , . . , .

-

:

  • - ;
  • ;
  • .
OOP Features




- - , . , , . - Java, “JavaBeans”, .

- . - javascript ecmascript, lua lo. :

  • ( - );
  • .

. , , .

-

- , . , .

OOP languages




:

  • , ;
  • ;
  • .

, :

  • , , ;
  • ;
  • ;
  • .

, - . , . , - . -.

, . , PHP JavaScript , , - . Java : -, , , -, . C# . , Java, . , Oz, , , .




All Articles