Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
АФТИ ООП 2013-2014. Лекция I/06
Search
Oleg Dashevskii
October 14, 2013
Education
0
140
АФТИ ООП 2013-2014. Лекция I/06
Oleg Dashevskii
October 14, 2013
Tweet
Share
More Decks by Oleg Dashevskii
See All by Oleg Dashevskii
Лекция № 13. Практическое руководство по разработке
be9
0
1.5k
Лекция № 12. Ещё о проектировании
be9
0
1.5k
Лекция № 11. Принцип отделения интерфейса. «Малое ООП»
be9
0
1.5k
Лекция № 10. Графическая нотация. Принципы LSP и DIP
be9
0
1.6k
Лекция № 9. Отношения между классами. Принцип открытия-закрытия
be9
0
1.5k
Лекция № 8. Хорошие и плохие ОО-программы
be9
0
1.5k
Лекция № 7. algorithm. Исключения
be9
1
1.5k
Лекция № 6. Стандартная библиотека C++. Часть 2
be9
0
1.6k
Лекция № 5. Стандартная библиотека C++. Часть 1
be9
0
1.6k
Other Decks in Education
See All in Education
Implicit and Cross-Device Interaction - Lecture 10 - Next Generation User Interfaces (4018166FNR)
signer
PRO
2
1.7k
2025年度春学期 統計学 第10回 分布の推測とは ー 標本調査,度数分布と確率分布 (2025. 6. 12)
akiraasano
PRO
0
140
AIC 103 - Applications of Property Valuation: Essential Slides
rmccaic
0
210
モンテカルロ法(3) 発展的アルゴリズム / Simulation 04
kaityo256
PRO
7
1.3k
2025年度春学期 統計学 第3回 クロス集計と感度・特異度,データの可視化 (2025. 4. 24)
akiraasano
PRO
0
130
Sponsor the Conference | VizChitra 2025
vizchitra
0
550
Course Review - Lecture 12 - Next Generation User Interfaces (4018166FNR)
signer
PRO
0
1.7k
推しのコミュニティはなんぼあってもいい / Let's join a lot of communities.
kaga
2
1.7k
2025/06/05_読み漁り学習
nag8
0
140
2025.05.10 技術書とVoicyとわたし #RPALT
kaitou
1
220
Pythonパッケージ管理 [uv] 完全入門
mickey_kubo
20
14k
『会社を知ってもらう』から『安心して活躍してもらう』までの プロセスとフロー
sasakendayo
0
230
Featured
See All Featured
Writing Fast Ruby
sferik
628
62k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
5
240
Build your cross-platform service in a week with App Engine
jlugia
231
18k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
34
5.9k
[RailsConf 2023] Rails as a piece of cake
palkan
55
5.6k
Rebuilding a faster, lazier Slack
samanthasiow
82
9.1k
4 Signs Your Business is Dying
shpigford
184
22k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
26k
Code Reviewing Like a Champion
maltzj
524
40k
For a Future-Friendly Web
brad_frost
179
9.8k
Producing Creativity
orderedlist
PRO
346
40k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
34
3.1k
Transcript
ОБЪЕКТНО- ОРИЕНТИРОВАННОЕ ПРОГРАММИРОВАНИЕ Лекция № 6 14.10.2013 г.
В ПРОШЛОЙ СЕРИИ • Single responsibility principle (SRP). • Наследование,
агрегация, композиция, ассоциация. • Задача 1. Применение ООП к stdio.h. • Задача 2. «Малое ООП». Задача линейной аппроксимации множества точек.
ПОТОКИ В C++ ios_base ios istream ostream iostream istringstream ifstream
filebuf
ПОТОКИ В QT QObject QIODevice QFile QTextStream QBuffer QProcess QAbstract
Socket и др.
class LinearRegression { public: LinearRegression(const QPointF *_points, int _size); LinearRegression(const
QVector<QPointF> &_points); // y=Ax+B double a(); double b(); QPointF point(double x) { return QPointF(x, a()*x+b()); } double mse(); double std(); protected: void calculate(); /****/ const QPointF *points; int size; bool ready; double _a, _b; };
ЗАДАЧА 2’ Проектирование класса для линейной экспоненциальной аппроксимации набора точек
class BaseRegression { public: BaseRegression(const QPointF *_points, int _size); BaseRegression(const
QVector<QPointF> &_points); virtual double y(double x)=0; QPointF point(double x) { return QPointF(x, y(x)); } double mse(); double std(); protected: /****/ const QPointF *points; int size; };
class ExponentialRegression : public BaseRegression { public: ExponentialRegression(const QVector<QPointF> &points);
// y=A*exp(B*x) double a(); double b(); double y(double x) { return a()*exp(b()*x); } protected: void calculate(); /****/ bool ready; double _a, _b; };
void ExponentialRegression::calculate() { QVector<QPointF> logpoints(size); for (int i = 0;
i < size; ++i) logpoints[i] = QPointF(points[i].x(), log(fabs(points[i].y()))); LinearRegression lr(logpoints); _b = lr.a(); _a = exp(lr.b()); if (size > 0 && points[0].y() < 0) _a *= -1; ready = true; }
void ExponentialRegression::calculate() { QVector<QPointF> logpoints(size); for (int i = 0;
i < size; ++i) logpoints[i] = QPointF(points[i].x(), log(fabs(points[i].y()))); LinearRegression lr(logpoints); _b = lr.a(); _a = exp(lr.b()); if (size > 0 && points[0].y() < 0) _a *= -1; ready = true; } Композиция
ЗАДАЧА 3 ОО-дизайн для задачи сортировки
КОНЕЦ ШЕСТОЙ ЛЕКЦИИ