SlideShare a Scribd company logo
1 of 19
C++ : наследование, часть 1 Дмитрий Штилерман, Рексофт
Краткое содержание первой части ,[object Object],[object Object],[object Object],[object Object],[object Object]
Открытое наследование (public inheritance) - отношение "is-a" class Person {}; class Student : public Person {}; class Teacher : public Person {}; void f(Person&)  {…} void g()  {   Student s;   Teacher t;   f(s);   f(t);  } Отношение “is-a”  организует объекты в виде  иерархической  классификации.
Виды классификаций ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Виды классификаций - иерархическая ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Млекопитающие Выкармливают детенышей молоком Приматы Всеядные, зубная система гетеродонтная, глаза направлены вперед Высшие обезьяны Нет хвоста
Виды классификаций - комбинативная ,[object Object],[object Object],[object Object],Высокие темпы роста Знаки вопроса Звезды Дойные коровы Собаки Низ кие темпы роста Большая доля рынка Малая доля рынка ???
Виды классификаций - параметрическая ,[object Object],[object Object],[object Object]
Отношение “is-a” -  как можно ошибиться? (1) class StupidBird  {public: virtual void fly() = 0;}; class StupidEagle : public StupidBird  {public: virtual void fly();}; class StupidPenguin : public StupidBird  {public: virtual void fly();}; Пингвины не умеют летать. Как мы собираемся реализовывать Stupid Penguin::fly()?
Отношение “is-a” -  как можно ошибиться? (2) class Rectangle  {   public:   int getHeight() const;   virtual void setHeight(int);   int getWidth() const;   virtual void setWidth(int);  }; void RectangleTest(Rectangle& r)  {   r.setHeight(4);    r.setWidth(5);   int S = r.getHeight()*r.getWidth();    assert(S==20);   } class Square : public Rectangle  {   public:   void setHeight(int h)   {   Rectangle::setHeight(h);   Rectangle::setWidth(h);   }   void setWidth(int w)   {   Rectangle::setWidth(w);   Rectangle::setHeight(w);   }  };
Отношение “is-a” -  как не ошибиться? ,[object Object],[object Object],[object Object]
Отношение “is-a” -  The Liskov Substitution Principle ,[object Object],[object Object],[object Object],[object Object]
Отношение “is-a” -  как исправить ошибку? (1) В рамках задачи неверно утверждение «все птицы умеют летать». Значит, неправильно делать  fly()  методом Bird. Решение из обычного орнитологического определителя: дополнительная теза-антитеза «летает - не летает».
Отношение “is-a” -  как исправить ошибку? (2) class Rectangular  {   public:   virtual int getHeight() const = 0;   virtual int getWidth() const = 0;  }; class Square : public Rectangular  {   public:   virtual int getHeight() const;   virtual int getWidth() const;   void setSide(int s);  }; class Rectangle : public Rectangular  {   public:   virtual int getHeight() const;   virtual int getWidth() const;   void setHeight(int h);   void setWidth(int w);  };
Наследование интерфейса и наследование реализации ,[object Object],[object Object],[object Object]
Наследование интерфейса class Shape  {public: virtual void draw() = 0;}; class Circle : public Shape  {public: virtual void draw();}; class Rectangle : public Shape  {public: virtual void draw();}; ,[object Object],[object Object],[object Object]
Наследование интерфейса и обязательной реализации class Shape  {   public:    virtual void draw() = 0;   virtual void erase() = 0;   bool getVisible() const   {return m_bVisible;}   void setVisible(bool bVisible)   {   m_bVisible = bVisible;   if(m_bVisible)   draw();   else   erase();    }   private:   bool m_bVisible;  }; ,[object Object],[object Object],[object Object],[object Object]
Наследование интерфейса и реализации по умолчанию (1) class Shape  {   public:    virtual void draw() = 0;   virtual void erase() = 0;   virtual void redraw()   {   /*  Простейший способ/    erase(); draw();   }  }; class Sprite : public Shape  {   public:   virtual void redraw()   {/* Оптимизированный способ*/}  }; ,[object Object],[object Object],[object Object],[object Object]
Наследование интерфейса и реализации по умолчанию (2) class Shape  {   public:    virtual void redraw() = 0;   protected:   void default_redraw()   {erase(); draw();}  }; class Rectangle : public Shape  {   public:   virtual void redraw()   {default_redraw();}  }; class Sprite : public Shape  {   public:   virtual void redraw()   {/*Оптимизированный способ*/}  }; ,[object Object],[object Object],[object Object],[object Object]
Продолжение в следующей серии ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]

More Related Content

What's hot

IBM Jazz - A New Approach For Software Development (In Russian)
IBM Jazz - A New Approach For Software Development (In Russian)IBM Jazz - A New Approach For Software Development (In Russian)
IBM Jazz - A New Approach For Software Development (In Russian)Alexander Klimov
 
Taleb's Black Swan - SG 20090520
Taleb's Black Swan - SG 20090520Taleb's Black Swan - SG 20090520
Taleb's Black Swan - SG 20090520beewolf
 
норма санпин
норма санпиннорма санпин
норма санпинhelen-66
 
Управление рисками ИБ: отдельные практические аспекты
Управление рисками ИБ: отдельные практические аспектыУправление рисками ИБ: отдельные практические аспекты
Управление рисками ИБ: отдельные практические аспектыAleksey Lukatskiy
 
Принцип Парето в стандартизации ИБ
Принцип Парето в стандартизации ИБПринцип Парето в стандартизации ИБ
Принцип Парето в стандартизации ИБAleksey Lukatskiy
 
Background Examples From Eu Ru
Background Examples From Eu RuBackground Examples From Eu Ru
Background Examples From Eu RuVictor Gridnev
 
Обеспечение безопасности web приложений
Обеспечение безопасности web приложенийОбеспечение безопасности web приложений
Обеспечение безопасности web приложенийSQALab
 
Сегментация рынка и сегментационные исследования
Сегментация рынка и сегментационные исследованияСегментация рынка и сегментационные исследования
Сегментация рынка и сегментационные исследованияabramamama
 
Библейские истории: Животные
Библейские истории: ЖивотныеБиблейские истории: Животные
Библейские истории: ЖивотныеFreekidstories
 
俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 1968
俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 1968俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 1968
俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 1968Armenia Laws
 
俄罗斯进出口标准,技术规格,法律,法规,中英文,目录编号RG 2657
俄罗斯进出口标准,技术规格,法律,法规,中英文,目录编号RG 2657俄罗斯进出口标准,技术规格,法律,法规,中英文,目录编号RG 2657
俄罗斯进出口标准,技术规格,法律,法规,中英文,目录编号RG 2657Turkmenistan Laws
 
Minsk Overview 190509 Tmpl
Minsk Overview 190509 TmplMinsk Overview 190509 Tmpl
Minsk Overview 190509 Tmplsef2009
 
俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3716
俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3716俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3716
俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3716Azerbaijan Laws
 
俄罗斯进出口标准,技术规格,法律,法规,中英文,目录编号RG 4397
俄罗斯进出口标准,技术规格,法律,法规,中英文,目录编号RG 4397俄罗斯进出口标准,技术规格,法律,法规,中英文,目录编号RG 4397
俄罗斯进出口标准,技术规格,法律,法规,中英文,目录编号RG 4397Russian Gost
 
俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3704
俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3704俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3704
俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3704Azerbaijan Laws
 
俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3403
俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3403俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3403
俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3403Azerbaijan Laws
 
俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 4103
俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 4103俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 4103
俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 4103Azerbaijan Laws
 

What's hot (19)

IBM Jazz - A New Approach For Software Development (In Russian)
IBM Jazz - A New Approach For Software Development (In Russian)IBM Jazz - A New Approach For Software Development (In Russian)
IBM Jazz - A New Approach For Software Development (In Russian)
 
Taleb's Black Swan - SG 20090520
Taleb's Black Swan - SG 20090520Taleb's Black Swan - SG 20090520
Taleb's Black Swan - SG 20090520
 
норма санпин
норма санпиннорма санпин
норма санпин
 
Управление рисками ИБ: отдельные практические аспекты
Управление рисками ИБ: отдельные практические аспектыУправление рисками ИБ: отдельные практические аспекты
Управление рисками ИБ: отдельные практические аспекты
 
Принцип Парето в стандартизации ИБ
Принцип Парето в стандартизации ИБПринцип Парето в стандартизации ИБ
Принцип Парето в стандартизации ИБ
 
Background Examples From Eu Ru
Background Examples From Eu RuBackground Examples From Eu Ru
Background Examples From Eu Ru
 
Обеспечение безопасности web приложений
Обеспечение безопасности web приложенийОбеспечение безопасности web приложений
Обеспечение безопасности web приложений
 
Сегментация рынка и сегментационные исследования
Сегментация рынка и сегментационные исследованияСегментация рынка и сегментационные исследования
Сегментация рынка и сегментационные исследования
 
Библейские истории: Животные
Библейские истории: ЖивотныеБиблейские истории: Животные
Библейские истории: Животные
 
俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 1968
俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 1968俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 1968
俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 1968
 
Postgre Sql 8 4
Postgre Sql 8 4Postgre Sql 8 4
Postgre Sql 8 4
 
俄罗斯进出口标准,技术规格,法律,法规,中英文,目录编号RG 2657
俄罗斯进出口标准,技术规格,法律,法规,中英文,目录编号RG 2657俄罗斯进出口标准,技术规格,法律,法规,中英文,目录编号RG 2657
俄罗斯进出口标准,技术规格,法律,法规,中英文,目录编号RG 2657
 
Minsk Overview 190509 Tmpl
Minsk Overview 190509 TmplMinsk Overview 190509 Tmpl
Minsk Overview 190509 Tmpl
 
俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3716
俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3716俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3716
俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3716
 
俄罗斯进出口标准,技术规格,法律,法规,中英文,目录编号RG 4397
俄罗斯进出口标准,技术规格,法律,法规,中英文,目录编号RG 4397俄罗斯进出口标准,技术规格,法律,法规,中英文,目录编号RG 4397
俄罗斯进出口标准,技术规格,法律,法规,中英文,目录编号RG 4397
 
俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3704
俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3704俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3704
俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3704
 
俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3403
俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3403俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3403
俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3403
 
俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 4103
俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 4103俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 4103
俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 4103
 
greek doc 1
greek doc 1greek doc 1
greek doc 1
 

Similar to OO Design with C++: 1. Inheritance, part 1

тупицын Ec2 Rootconf2009
тупицын Ec2 Rootconf2009тупицын Ec2 Rootconf2009
тупицын Ec2 Rootconf2009Liudmila Li
 
Cisco collaboration. 8_oktiabria_biznes-trek_litsenzirovanie
Cisco collaboration. 8_oktiabria_biznes-trek_litsenzirovanieCisco collaboration. 8_oktiabria_biznes-trek_litsenzirovanie
Cisco collaboration. 8_oktiabria_biznes-trek_litsenzirovanieMichael Ganschuk
 
vSphere Launch Business Keynote - Москва, 26 мая
vSphere Launch Business Keynote - Москва, 26 маяvSphere Launch Business Keynote - Москва, 26 мая
vSphere Launch Business Keynote - Москва, 26 маяAnton Antich
 
норма санпин
норма санпиннорма санпин
норма санпинhelen-66
 
Aids 14.01.2009
Aids 14.01.2009Aids 14.01.2009
Aids 14.01.2009Oleg Zorak
 
Aids 14.01.2009
Aids 14.01.2009Aids 14.01.2009
Aids 14.01.2009Oleg Zorak
 
俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3411
俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3411俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3411
俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3411Azerbaijan Laws
 
俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3701
俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3701俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3701
俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3701Azerbaijan Laws
 
Учет рабочего времени сотрудников: полное руководство
Учет рабочего времени сотрудников: полное руководство Учет рабочего времени сотрудников: полное руководство
Учет рабочего времени сотрудников: полное руководство Yaware
 
俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3457
俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3457俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3457
俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3457Azerbaijan Laws
 
Minsk Web Appl 190509
Minsk Web Appl 190509Minsk Web Appl 190509
Minsk Web Appl 190509sef2009
 
俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3434
俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3434俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3434
俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3434Azerbaijan Laws
 
俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3455
俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3455俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3455
俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3455Azerbaijan Laws
 
OO Design with C++: 2. Inheritance, part 2
OO Design with C++: 2. Inheritance, part 2OO Design with C++: 2. Inheritance, part 2
OO Design with C++: 2. Inheritance, part 2Dmitry Stillermann
 

Similar to OO Design with C++: 1. Inheritance, part 1 (20)

тупицын Ec2 Rootconf2009
тупицын Ec2 Rootconf2009тупицын Ec2 Rootconf2009
тупицын Ec2 Rootconf2009
 
Cisco collaboration. 8_oktiabria_biznes-trek_litsenzirovanie
Cisco collaboration. 8_oktiabria_biznes-trek_litsenzirovanieCisco collaboration. 8_oktiabria_biznes-trek_litsenzirovanie
Cisco collaboration. 8_oktiabria_biznes-trek_litsenzirovanie
 
vSphere Launch Business Keynote - Москва, 26 мая
vSphere Launch Business Keynote - Москва, 26 маяvSphere Launch Business Keynote - Москва, 26 мая
vSphere Launch Business Keynote - Москва, 26 мая
 
Grape Online Strategy Cases
Grape Online Strategy CasesGrape Online Strategy Cases
Grape Online Strategy Cases
 
Beauty
BeautyBeauty
Beauty
 
EU Competition Policy
EU Competition PolicyEU Competition Policy
EU Competition Policy
 
20070613 Rit2007 Training
20070613 Rit2007 Training20070613 Rit2007 Training
20070613 Rit2007 Training
 
норма санпин
норма санпиннорма санпин
норма санпин
 
Aids 14.01.2009
Aids 14.01.2009Aids 14.01.2009
Aids 14.01.2009
 
Aids 14.01.2009
Aids 14.01.2009Aids 14.01.2009
Aids 14.01.2009
 
俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3411
俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3411俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3411
俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3411
 
俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3701
俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3701俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3701
俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3701
 
Unittests
UnittestsUnittests
Unittests
 
Учет рабочего времени сотрудников: полное руководство
Учет рабочего времени сотрудников: полное руководство Учет рабочего времени сотрудников: полное руководство
Учет рабочего времени сотрудников: полное руководство
 
俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3457
俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3457俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3457
俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3457
 
Minsk Web Appl 190509
Minsk Web Appl 190509Minsk Web Appl 190509
Minsk Web Appl 190509
 
俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3434
俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3434俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3434
俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3434
 
俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3455
俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3455俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3455
俄语GOST标准,技术规范,法律,法规,中文英语,目录编号RG 3455
 
Engl Info
Engl InfoEngl Info
Engl Info
 
OO Design with C++: 2. Inheritance, part 2
OO Design with C++: 2. Inheritance, part 2OO Design with C++: 2. Inheritance, part 2
OO Design with C++: 2. Inheritance, part 2
 

More from Dmitry Stillermann

Как расти самому, помогая расти другим — практическое применение Management T...
Как расти самому, помогая расти другим — практическое применение Management T...Как расти самому, помогая расти другим — практическое применение Management T...
Как расти самому, помогая расти другим — практическое применение Management T...Dmitry Stillermann
 
OO Design with C++: 4. Design Principles, part 1
OO Design with C++: 4. Design Principles, part 1OO Design with C++: 4. Design Principles, part 1
OO Design with C++: 4. Design Principles, part 1Dmitry Stillermann
 
OO Design with C++: 5. Design Principles, part 2
OO Design with C++: 5. Design Principles, part 2OO Design with C++: 5. Design Principles, part 2
OO Design with C++: 5. Design Principles, part 2Dmitry Stillermann
 
OO Design with C++: 3. Inheritance, part 3
OO Design with C++: 3. Inheritance, part 3OO Design with C++: 3. Inheritance, part 3
OO Design with C++: 3. Inheritance, part 3Dmitry Stillermann
 
OO Design with C++: 6. Templates & Patterns
OO Design with C++: 6. Templates & PatternsOO Design with C++: 6. Templates & Patterns
OO Design with C++: 6. Templates & PatternsDmitry Stillermann
 

More from Dmitry Stillermann (7)

DiSC Model in Practice
DiSC Model in PracticeDiSC Model in Practice
DiSC Model in Practice
 
Как расти самому, помогая расти другим — практическое применение Management T...
Как расти самому, помогая расти другим — практическое применение Management T...Как расти самому, помогая расти другим — практическое применение Management T...
Как расти самому, помогая расти другим — практическое применение Management T...
 
OO Design with C++: 4. Design Principles, part 1
OO Design with C++: 4. Design Principles, part 1OO Design with C++: 4. Design Principles, part 1
OO Design with C++: 4. Design Principles, part 1
 
OO Design with C++: 5. Design Principles, part 2
OO Design with C++: 5. Design Principles, part 2OO Design with C++: 5. Design Principles, part 2
OO Design with C++: 5. Design Principles, part 2
 
OO Design with C++: 3. Inheritance, part 3
OO Design with C++: 3. Inheritance, part 3OO Design with C++: 3. Inheritance, part 3
OO Design with C++: 3. Inheritance, part 3
 
OO Design with C++: 6. Templates & Patterns
OO Design with C++: 6. Templates & PatternsOO Design with C++: 6. Templates & Patterns
OO Design with C++: 6. Templates & Patterns
 
OO Design with C++: 0. Intro
OO Design with C++: 0. IntroOO Design with C++: 0. Intro
OO Design with C++: 0. Intro
 

Recently uploaded

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 

Recently uploaded (20)

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 

OO Design with C++: 1. Inheritance, part 1

  • 1. C++ : наследование, часть 1 Дмитрий Штилерман, Рексофт
  • 2.
  • 3. Открытое наследование (public inheritance) - отношение "is-a" class Person {}; class Student : public Person {}; class Teacher : public Person {}; void f(Person&) {…} void g() { Student s; Teacher t; f(s); f(t); } Отношение “is-a” организует объекты в виде иерархической классификации.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8. Отношение “is-a” - как можно ошибиться? (1) class StupidBird {public: virtual void fly() = 0;}; class StupidEagle : public StupidBird {public: virtual void fly();}; class StupidPenguin : public StupidBird {public: virtual void fly();}; Пингвины не умеют летать. Как мы собираемся реализовывать Stupid Penguin::fly()?
  • 9. Отношение “is-a” - как можно ошибиться? (2) class Rectangle { public: int getHeight() const; virtual void setHeight(int); int getWidth() const; virtual void setWidth(int); }; void RectangleTest(Rectangle& r) { r.setHeight(4); r.setWidth(5); int S = r.getHeight()*r.getWidth(); assert(S==20); } class Square : public Rectangle { public: void setHeight(int h) { Rectangle::setHeight(h); Rectangle::setWidth(h); } void setWidth(int w) { Rectangle::setWidth(w); Rectangle::setHeight(w); } };
  • 10.
  • 11.
  • 12. Отношение “is-a” - как исправить ошибку? (1) В рамках задачи неверно утверждение «все птицы умеют летать». Значит, неправильно делать fly() методом Bird. Решение из обычного орнитологического определителя: дополнительная теза-антитеза «летает - не летает».
  • 13. Отношение “is-a” - как исправить ошибку? (2) class Rectangular { public: virtual int getHeight() const = 0; virtual int getWidth() const = 0; }; class Square : public Rectangular { public: virtual int getHeight() const; virtual int getWidth() const; void setSide(int s); }; class Rectangle : public Rectangular { public: virtual int getHeight() const; virtual int getWidth() const; void setHeight(int h); void setWidth(int w); };
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.

Editor's Notes

  1. Public vs. protected interface - two types of clients {part. Meyers1.41}. Containment as "has-a" or "is-implemented-via" relationship {Meyers1.40} Private inheritance - reasons of use instead of containment {Meyers1.42}