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
万博非公式マップとFOSS4G
barsaka2
0
1.1k
Présentation_1ère_Spé_2025.pdf
bernhardsvt
0
220
GitHubとAzureを使って開発者になろう
ymd65536
1
160
20250807_がんばらないコミュニティ運営
ponponmikankan
0
160
2025年度春学期 統計学 第13回 不確かな測定の不確かさを測る ー 不偏分散とt分布 (2025. 7. 3)
akiraasano
PRO
0
120
【品女100周年企画】Pitch Deck
shinagawajoshigakuin_100th
0
5.9k
(キラキラ)人事教育担当のつらみ~教育担当として知っておくポイント~
masakiokuda
0
130
令和政経義塾第2期説明会
nxji
0
200
学びは趣味の延長線
ohmori_yusuke
0
100
Case Studies and Course Review - Lecture 12 - Information Visualisation (4019538FNR)
signer
PRO
1
2.1k
[FUN Open Campus 2025] 何でもセンシングしていいですか?
pman0214
0
240
Pydantic(AI)とJSONの詳細解説
mickey_kubo
0
190
Featured
See All Featured
How STYLIGHT went responsive
nonsquared
100
5.8k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
139
34k
Site-Speed That Sticks
csswizardry
10
810
Reflections from 52 weeks, 52 projects
jeffersonlam
352
21k
Building a Scalable Design System with Sketch
lauravandoore
462
33k
Building an army of robots
kneath
306
46k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
The Pragmatic Product Professional
lauravandoore
36
6.9k
How to train your dragon (web standard)
notwaldorf
96
6.2k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
667
120k
Thoughts on Productivity
jonyablonski
70
4.8k
The Power of CSS Pseudo Elements
geoffreycrofte
77
6k
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 ОО-дизайн для задачи сортировки
КОНЕЦ ШЕСТОЙ ЛЕКЦИИ